1
- /**
2
- * Metro configuration for React Native
3
- * https://github.com/facebook/react-native
4
- *
5
- * @format
6
- */
7
-
1
+ const { getDefaultConfig, mergeConfig} = require ( '@react-native/metro-config' ) ;
8
2
const path = require ( 'path' ) ;
9
- const exclusionList = ( ( ) => {
10
- try {
11
- return require ( 'metro-config/src/defaults/exclusionList' ) ;
12
- } catch ( _ ) {
13
- // `blacklist` was renamed to `exclusionList` in 0.60
14
- return require ( 'metro-config/src/defaults/blacklist' ) ;
15
- }
16
- } ) ( ) ;
3
+ const exclusionList = require ( 'metro-config/src/defaults/exclusionList' ) ;
17
4
const escape = require ( 'escape-string-regexp' ) ;
18
5
const pack = require ( '../package.json' ) ;
19
6
20
7
const root = path . resolve ( __dirname , '..' ) ;
21
-
22
8
const modules = [ ...Object . keys ( pack . peerDependencies ) ] ;
23
9
24
10
const blockList = exclusionList ( [
25
11
/ n o d e _ m o d u l e s \/ .* \/ n o d e _ m o d u l e s \/ r e a c t - n a t i v e \/ .* / ,
26
-
27
12
// This stops "react-native run-windows" from causing the metro server to
28
13
// crash if its already running
29
14
new RegExp ( `${ path . join ( __dirname , 'windows' ) . replace ( / [ / \\ ] + / g, '/' ) } .*` ) ,
30
-
31
15
// Workaround for `EPERM: operation not permitted, lstat '~\midl-MIDLRT-cl.read.1.tlog'`
32
16
/ .* \. t l o g / ,
33
-
34
17
// Prevent Metro from watching temporary files generated by Visual Studio
35
18
// otherwise it may crash when they are removed when closing a project.
36
19
/ .* \/ .v s \/ .* / ,
37
-
38
20
// Workaround for `EBUSY: resource busy or locked, open '~\msbuild.ProjectImports.zip'`
39
21
/ .* \. P r o j e c t I m p o r t s \. z i p / ,
40
-
41
22
...modules . map (
42
23
( m ) => new RegExp ( `^${ escape ( path . join ( root , 'node_modules' , m ) ) } \\/.*$` ) ,
43
24
) ,
44
25
] ) ;
45
26
46
- module . exports = {
27
+ const config = {
47
28
projectRoot : __dirname ,
48
29
watchFolders : [ root ] ,
49
30
resolver : {
50
- blacklistRE : blockList ,
51
31
blockList,
32
+ blacklistRE : blockList ,
52
33
extraNodeModules : modules . reduce ( ( acc , name ) => {
53
34
acc [ name ] = path . join ( __dirname , 'node_modules' , name ) ;
54
35
return acc ;
55
36
} , { } ) ,
37
+ assetExts : [ ...getDefaultConfig ( __dirname ) . resolver . assetExts , 'png' ] ,
56
38
} ,
57
39
transformer : {
58
40
getTransformOptions : async ( ) => ( {
@@ -63,3 +45,5 @@ module.exports = {
63
45
} ) ,
64
46
} ,
65
47
} ;
48
+
49
+ module . exports = mergeConfig ( getDefaultConfig ( __dirname ) , config ) ;
0 commit comments