Skip to content

Instantly share code, notes, and snippets.

@mickdelaney
Forked from sibelius/metro.config.js
Created January 8, 2022 17:19
Show Gist options
  • Select an option

  • Save mickdelaney/0cf9cb51d5127a8e7b76d843c9cd9034 to your computer and use it in GitHub Desktop.

Select an option

Save mickdelaney/0cf9cb51d5127a8e7b76d843c9cd9034 to your computer and use it in GitHub Desktop.
Metro config to make react native play nice with monorepos
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, 'packages/app'),
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, 'packages/app/node_modules/react-native'),
},
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment