Skip to content

Instantly share code, notes, and snippets.

@hkjels
Created May 18, 2022 07:40
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 hkjels/f1938e7b3f89f929cbd071f490c55c6d to your computer and use it in GitHub Desktop.
Save hkjels/f1938e7b3f89f929cbd071f490c55c6d to your computer and use it in GitHub Desktop.
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