Skip to content

Commit

Permalink
examples: react-native-web: fix config to prefer .web.* exts (#10774)
Browse files Browse the repository at this point in the history
* [examples/with-react-native-web] fix config to get .web.* extensions resolved before other

Simple issue if you have `Compo.js` & `Compo.web.js` (eg 1st for iOS/android & second for web): with current config, .web are resolved after.
My change change this situation so web extensions are resolved before the others.

I removed the `defaultLoaders` since it was not used. Tell me if that was intentional so I can add it back.

* lint-fix

Co-authored-by: Joe Haddad <timer150@gmail.com>
  • Loading branch information
MoOx and Timer committed Mar 1, 2020
1 parent 8999ef2 commit 644a1ef
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions examples/with-react-native-web/next.config.js
@@ -1,11 +1,16 @@
module.exports = {
webpack: (config, { defaultLoaders }) => {
webpack: config => {
config.resolve.alias = {
...(config.resolve.alias || {}),
// Transform all direct `react-native` imports to `react-native-web`
'react-native$': 'react-native-web',
}
config.resolve.extensions.push('.web.js', '.web.ts', '.web.tsx')
config.resolve.extensions = [
'.web.js',
'.web.ts',
'.web.tsx',
...config.resolve.extensions,
]
return config
},
}

0 comments on commit 644a1ef

Please sign in to comment.