Add babel plugin to rewrite import paths

Replace 'react-native' imports with direct imports to the relevant
module within 'react-native-web'. Follow up task is to also rewrite
'react-native-web' imports from the entry file to become direct imports
(reduces bundle size).

Close #608
This commit is contained in:
Paul Armstrong
2017-08-17 08:45:43 -07:00
committed by Nicolas Gallagher
parent 641c8c47e0
commit 7e8ef5b72c
6 changed files with 341 additions and 304 deletions
+3 -4
View File
@@ -34,6 +34,9 @@ const babelLoaderConfiguration = {
loader: 'babel-loader',
options: {
cacheDirectory: true,
// This aliases 'react-native' to 'react-native-web' and includes only
// the modules needed by the app
plugins: ['react-native-web/babel']
// The 'react-native' preset is recommended (or use your own .babelrc)
presets: ['react-native']
}
@@ -71,10 +74,6 @@ module.exports = {
],
resolve: {
// Maps the 'react-native' import to 'react-native-web'.
alias: {
'react-native': 'react-native-web'
},
// If you're working on a multi-platform React Native app, web-specific
// module implementations should be written in files using the extension
// `.web.js`.