-
Notifications
You must be signed in to change notification settings - Fork 58
/
rn-cli-inside-gb.config.js
39 lines (33 loc) · 1.33 KB
/
rn-cli-inside-gb.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
34
35
36
37
38
39
/** @format */
const path = require( 'path' );
const blacklist = require( 'metro-config/src/defaults/blacklist' );
// Blacklist the nested GB filetree so modules are not resolved in duplicates,
// both in the nested directory and the parent directory.
const blacklistElements = blacklist( [
new RegExp( path.basename( __dirname ) + '/gutenberg/.*' ),
] );
const enm = require( './extra-node-modules.config.js' );
const { lstatSync, readdirSync } = require( 'fs' );
const getDirectoryNames = ( dir ) =>
readdirSync( dir ).filter( ( name ) => lstatSync( path.resolve( dir, name ) ).isDirectory() );
const wppackagenames = getDirectoryNames( path.resolve( __dirname, '../packages/' ) );
const mapper = function( accu, v ) {
accu[ '@wordpress/' + v ] = path.resolve( __dirname, '../packages/' + v );
return accu;
};
const wppackages = wppackagenames.reduce( mapper, {} );
const alternateRoots = [ path.resolve( __dirname, '../node_modules' ) ].concat(
Object.values( wppackages )
);
module.exports = {
extraNodeModules: Object.assign( enm, wppackages ),
watchFolders: alternateRoots,
resolver: {
blacklistRE: blacklistElements,
sourceExts: [ 'js', 'json', 'scss', 'sass' ],
providesModuleNodeModules: [ 'react-native-svg', 'react-native' ],
},
transformer: {
babelTransformerPath: require.resolve( './sass-transformer-inside-gb.js' ),
},
};