Skip to content

Instantly share code, notes, and snippets.

@sibelius
Created March 1, 2019 12:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sibelius/14d0ecdbd917959c0f7b6f1c4f81f850 to your computer and use it in GitHub Desktop.
Save sibelius/14d0ecdbd917959c0f7b6f1c4f81f850 to your computer and use it in GitHub Desktop.
metro config to work with yarn workspaces
const path = require('path');
const getWorkspaces = require('get-yarn-workspaces');
const blacklist = require('metro-config/src/defaults/blacklist');
const workspaces = getWorkspaces(__dirname);
module.exports = {
projectRoot: path.resolve(__dirname, '.'),
watchFolders: [
path.resolve(__dirname, '../../node_modules'),
...workspaces,
],
resolver: {
blacklistRE: blacklist(
workspaces.map(
workspacePath =>
`/${workspacePath.replace(
/\//g,
'[/\\\\]'
)}[/\\\\]node_modules[/\\\\]react-native[/\\\\].*/`
),
),
extraNodeModules: {
'react-native': path.resolve(__dirname, 'node_modules/react-native'),
},
},
};
@vanGalilea
Copy link

The blacklist file seems to be renamed as exclusionList

const blacklist = require('metro-config/src/defaults/exclusionList');
use this line instead

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