Skip to content

Instantly share code, notes, and snippets.

@KEMBL
Created March 4, 2020 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KEMBL/366d1e3b1c89941be1efc9bd358920d2 to your computer and use it in GitHub Desktop.
Save KEMBL/366d1e3b1c89941be1efc9bd358920d2 to your computer and use it in GitHub Desktop.
/**
* Metro configuration for React Native
*
* @format
*/
const fs = require('fs');
const path = require('path');
const config = {
projectRoot: path.resolve(__dirname),
watchFolders: [
path.resolve(__dirname, '../../node_modules'),
path.resolve(__dirname, '..')
],
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false
}
})
},
resolver: {
blacklistRE: /(.*\\components\\node_modules\\.*|.*\\rns-theme\\node_modules\\.*|.*\\rns-core\\node_modules\\.*)$/,
extraNodeModules: new Proxy(
{},
{
get: (target, name) => {
// 1. from self modules
let componentPath = path.join(__dirname, `node_modules/${name}`);
if (fs.existsSync(componentPath)) {
return componentPath;
}
// 2. from root modules
componentPath = path.join(__dirname, `../../node_modules/${name}`);
if (fs.existsSync(componentPath)) {
return componentPath;
}
console.warn(
`component ${name} is not found at path ${componentPath}`
);
return componentPath;
}
}
),
sourceExts: ['ts', 'tsx', 'js', 'jsx']
}
};
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment