Created
May 18, 2022 07:40
-
-
Save hkjels/f1938e7b3f89f929cbd071f490c55c6d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const config = require('./metro.config.js'); | |
const fs = require('fs'); | |
const path = require('path'); | |
const exclusionList = require('metro-config/src/defaults/exclusionList'); | |
const rnPath = fs.realpathSync( | |
path.resolve(require.resolve('react-native/package.json'), '..'), | |
); | |
const assetRegistryPath = fs.realpathSync( | |
path.resolve( | |
require.resolve('react-native-web/dist/modules/AssetRegistry/index.js'), | |
'..', | |
), | |
); | |
module.exports = { | |
...config, | |
transformer: { | |
...config.transformer, | |
assetRegistryPath, | |
}, | |
resolver: { | |
...config.resolver, | |
platforms: ['android', 'ios', 'native', 'web'], | |
extraNodeModules: new Proxy( | |
{}, | |
{ | |
get: (target, name) => { | |
if (name === 'react-native') { | |
return path.join(__dirname, `node_modules/${name}-web`); | |
} | |
return path.join(__dirname, `node_modules/${name}`); | |
}, | |
}, | |
), | |
blockList: exclusionList([ | |
new RegExp( | |
`${(path.resolve(rnPath) + path.sep).replace(/[/\\\\]/g, '[/\\\\]')}.*`, | |
), | |
new RegExp( | |
`${path.resolve(__dirname, 'web').replace(/[/\\\\]/g, '[/\\\\]')}.*`, | |
), | |
]), | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment