-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetro.config.js
33 lines (28 loc) · 1.13 KB
/
metro.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');
const fs = require('fs');
const path = require('path');
/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);
config.server = {
...config.server,
/**
* THEOplayer needs to load its transmux libraries dynamically, so copy them from the npm package to the public
* folder.
*/
enhanceMiddleware: (middleware, server) => {
const sourceFolder = path.resolve(__dirname, 'node_modules/theoplayer');
const targetFolder = path.resolve(__dirname, 'public/theoplayer');
if (!fs.existsSync(targetFolder)) {
fs.mkdirSync(targetFolder, { recursive: true });
}
fs.readdirSync(sourceFolder).forEach(file => {
const sourcePath = path.join(sourceFolder, file);
const targetPath = path.join(targetFolder, file);
fs.copyFileSync(sourcePath, targetPath);
console.log(`Copied ${file} to ${targetFolder}`);
});
return middleware;
},
};
module.exports = config;