Skip to content

Commit 9527b77

Browse files
mini-eggsromaindso
authored andcommitted
Better React Native Web support (facebook#2511)
* Better React Native Web support * Adding better react-native-web support for jest testing
1 parent 4d24e66 commit 9527b77

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

packages/react-scripts/config/webpack.config.dev.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ module.exports = {
9494
// We also include JSX as a common component filename extension to support
9595
// some tools, although we do not recommend using it, see:
9696
// https://github.com/facebookincubator/create-react-app/issues/290
97-
extensions: ['.js', '.json', '.jsx'],
97+
// `web` extension prefixes have been added for better support
98+
// for React Native Web.
99+
extensions: ['.web.js', '.js', '.json', '.web.jsx', '.jsx'],
98100
alias: {
99101
// @remove-on-eject-begin
100102
// Resolve Babel runtime relative to react-scripts.

packages/react-scripts/config/webpack.config.prod.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ module.exports = {
9494
// We also include JSX as a common component filename extension to support
9595
// some tools, although we do not recommend using it, see:
9696
// https://github.com/facebookincubator/create-react-app/issues/290
97-
extensions: ['.js', '.json', '.jsx'],
97+
// `web` extension prefixes have been added for better support
98+
// for React Native Web.
99+
extensions: ['.web.js', '.js', '.json', '.web.jsx', '.jsx'],
98100
alias: {
99101
// @remove-on-eject-begin
100102
// Resolve Babel runtime relative to react-scripts.

packages/react-scripts/scripts/utils/createJestConfig.js

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module.exports = (resolve, rootDir, isEjecting) => {
4343
moduleNameMapper: {
4444
'^react-native$': 'react-native-web',
4545
},
46+
moduleFileExtensions: ['web.js', 'js', 'json', 'web.jsx', 'jsx'],
4647
};
4748
if (rootDir) {
4849
config.rootDir = rootDir;

0 commit comments

Comments
 (0)