-
Notifications
You must be signed in to change notification settings - Fork 1
/
metro.config.js.old
41 lines (31 loc) · 1.17 KB
/
metro.config.js.old
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
34
35
36
37
38
39
40
41
// Learn more https://docs.expo.io/guides/customizing-metro
// Add support for svg files: https://github.com/react-native-svg/react-native-svg#use-with-svg-files
const { getDefaultConfig } = require('expo/metro-config');
const path = require('path');
const fs = require('fs');
function getWorkspaceRoot() {
const packageFile = path.join(__dirname, '../../package.json');
const packageContent = fs.existsSync(packageFile) ? fs.readFileSync(packageFile, 'utf-8') : null;
if (packageContent && JSON.parse(packageContent).name === '@wcpos/monorepo') {
console.log('Found workspace root');
return path.resolve(__dirname, '../..');
}
return null;
}
const projectRoot = __dirname;
const workspaceRoot = getWorkspaceRoot();
module.exports = (() => {
const config = getDefaultConfig(__dirname);
const {
resolver: { sourceExts, assetExts },
} = config;
if (workspaceRoot) {
config.watchFolders = [workspaceRoot];
}
config.resolver.disableHierarchicalLookup = true;
config.resolver.nodeModulesPaths = [path.resolve(projectRoot, 'node_modules')];
if (workspaceRoot) {
config.resolver.nodeModulesPaths.push(path.resolve(workspaceRoot, 'node_modules'));
}
return config;
})();