-
Notifications
You must be signed in to change notification settings - Fork 444
Expand file tree
/
Copy pathmetro.config.js
More file actions
48 lines (39 loc) · 1.34 KB
/
metro.config.js
File metadata and controls
48 lines (39 loc) · 1.34 KB
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
42
43
44
45
46
47
const path = require('path');
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
/**
* Metro configuration
* https://reactnative.dev/docs/metro
*
* @type {import('@react-native/metro-config').MetroConfig}
*/
const defaultConfig = getDefaultConfig(__dirname);
const { assetExts, sourceExts } = defaultConfig.resolver;
// Absolute path to your local library
const rnBGGeo = path.resolve(
__dirname,
'../../' // <--
);
// Helper to escape path in RegExp for blockList
const esc = p => p.replace(/[/\\]/g, '[\\/\\\\]');
const config = {
watchFolders: [rnBGGeo],
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
},
resolver: {
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg'],
// Prefer the app's copies of these to avoid duplicates from the linked lib
extraNodeModules: {
react: path.resolve(__dirname, 'node_modules/react'),
'react-native': path.resolve(__dirname, 'node_modules/react-native'),
},
// Keep Metro from crawling the lib's nested RN (if any)
blockList: [
new RegExp(`${esc(rnBGGeo)}${esc('/node_modules/react-native/')}.+`),
],
// Newer Metro supports this (helps with symlinks)
unstable_enableSymlinks: true,
},
};
module.exports = mergeConfig(defaultConfig, config);