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' ) ;
82const 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' ) ;
174const escape = require ( 'escape-string-regexp' ) ;
185const pack = require ( '../package.json' ) ;
196
207const root = path . resolve ( __dirname , '..' ) ;
21-
228const modules = [ ...Object . keys ( pack . peerDependencies ) ] ;
239
2410const blockList = exclusionList ( [
2511 / 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-
2712 // This stops "react-native run-windows" from causing the metro server to
2813 // crash if its already running
2914 new RegExp ( `${ path . join ( __dirname , 'windows' ) . replace ( / [ / \\ ] + / g, '/' ) } .*` ) ,
30-
3115 // Workaround for `EPERM: operation not permitted, lstat '~\midl-MIDLRT-cl.read.1.tlog'`
3216 / .* \. t l o g / ,
33-
3417 // Prevent Metro from watching temporary files generated by Visual Studio
3518 // otherwise it may crash when they are removed when closing a project.
3619 / .* \/ .v s \/ .* / ,
37-
3820 // Workaround for `EBUSY: resource busy or locked, open '~\msbuild.ProjectImports.zip'`
3921 / .* \. P r o j e c t I m p o r t s \. z i p / ,
40-
4122 ...modules . map (
4223 ( m ) => new RegExp ( `^${ escape ( path . join ( root , 'node_modules' , m ) ) } \\/.*$` ) ,
4324 ) ,
4425] ) ;
4526
46- module . exports = {
27+ const config = {
4728 projectRoot : __dirname ,
4829 watchFolders : [ root ] ,
4930 resolver : {
50- blacklistRE : blockList ,
5131 blockList,
32+ blacklistRE : blockList ,
5233 extraNodeModules : modules . reduce ( ( acc , name ) => {
5334 acc [ name ] = path . join ( __dirname , 'node_modules' , name ) ;
5435 return acc ;
5536 } , { } ) ,
37+ assetExts : [ ...getDefaultConfig ( __dirname ) . resolver . assetExts , 'png' ] ,
5638 } ,
5739 transformer : {
5840 getTransformOptions : async ( ) => ( {
@@ -63,3 +45,5 @@ module.exports = {
6345 } ) ,
6446 } ,
6547} ;
48+
49+ module . exports = mergeConfig ( getDefaultConfig ( __dirname ) , config ) ;
0 commit comments