Skip to content

Instantly share code, notes, and snippets.

@xiongemi
Last active April 11, 2022 04:50
Show Gist options
  • Save xiongemi/e52600f2b5a0712b1e65f96fc95aede9 to your computer and use it in GitHub Desktop.
Save xiongemi/e52600f2b5a0712b1e65f96fc95aede9 to your computer and use it in GitHub Desktop.
babelrc and webpack for react native web
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic"
}
]
],
"plugins": [["react-native-web", { "commonjs": true }]]
}
const getWebpackConfig = require('@nrwl/react/plugins/webpack');
function getCustomWebpackConfig(webpackConfig) {
const config = getWebpackConfig(webpackConfig);
config.resolve.alias = {
'react-native': 'react-native-web',
};
config.module.rules.push({
test: /\.(js|jsx)$/,
exclude: /node_modules[/\\](?!react-native-vector-icons)/,
use: {
loader: require.resolve('@nrwl/web/src/utils/web-babel-loader.js'),
options: {
presets: [
[
'@nrwl/react/babel',
{
runtime: 'automatic',
},
],
]
},
},
});
return config;
}
module.exports = getCustomWebpackConfig;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment