Created
March 4, 2020 21:18
-
-
Save KEMBL/366d1e3b1c89941be1efc9bd358920d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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