Skip to content

Instantly share code, notes, and snippets.

@Wellers0n
Created June 30, 2019 23:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wellers0n/62dcdc676a8886c1eb99486fdf395ceb to your computer and use it in GitHub Desktop.
Save Wellers0n/62dcdc676a8886c1eb99486fdf395ceb to your computer and use it in GitHub Desktop.
metro config to monorepo
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/
const path = require('path');
const getWorkspaces = require('get-yarn-workspaces');
const workspaces = getWorkspaces(__dirname);
const blacklist = require('metro-config/src/defaults/blacklist');
module.exports = {
projectRoot: path.resolve(__dirname, '.'),
// watchFolders: [path.resolve(__dirname, './node_modules')],
watchFolders: [
path.resolve(__dirname, '../../node_modules'),
...workspaces,
],
resolver: {
blacklistRE: blacklist([
/node_modules\/.*\/node_modules\/react-native\/.*/,
]),
// https://github.com/facebook/metro/issues/1#issuecomment-453450709
extraNodeModules: new Proxy({}, {
get: (target, name) => path.join(process.cwd(), `node_modules/${name}`),
}),
},
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
@enzomanuelmangano
Copy link

enzomanuelmangano commented Sep 21, 2021

Super useful. Thanks a lot 🙏🏼.

Just a quick note: recently 'metro-config/src/defaults/blacklist' has been renamed into 'metro-config/src/defaults/exclusionList'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment