Last active
April 11, 2022 04:50
-
-
Save xiongemi/e52600f2b5a0712b1e65f96fc95aede9 to your computer and use it in GitHub Desktop.
babelrc and webpack for react native web
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
Show hidden characters
{ | |
"presets": [ | |
[ | |
"@nrwl/react/babel", | |
{ | |
"runtime": "automatic" | |
} | |
] | |
], | |
"plugins": [["react-native-web", { "commonjs": true }]] | |
} |
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
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