From fea70dbdd3c48a6d7e70b107409ef0f873a24a32 Mon Sep 17 00:00:00 2001 From: Alpha Shuro Date: Tue, 15 Nov 2016 21:21:52 +0200 Subject: [PATCH 1/2] resolve imports from src --- packages/react-scripts/config/webpack.config.dev.js | 5 ++++- packages/react-scripts/config/webpack.config.prod.js | 5 ++++- packages/react-scripts/utils/createJestConfig.js | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index c2b544cca54..419a91d0463 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -74,9 +74,12 @@ module.exports = { publicPath: publicPath }, resolve: { + // allows importing from the 'src' folder + // to avoid having to type long relative paths to get back up the folder hierarchy + root: [ paths.appSrc ], // This allows you to set a fallback for where Webpack should look for modules. // We read `NODE_PATH` environment variable in `paths.js` and pass paths here. - // We use `fallback` instead of `root` because we want `node_modules` to "win" + // We use `fallback` because we want `node_modules` to "win" // if there any conflicts. This matches Node resolution mechanism. // https://github.com/facebookincubator/create-react-app/issues/253 fallback: paths.nodePaths, diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index e0141b851b4..c29717a38d4 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -80,9 +80,12 @@ module.exports = { publicPath: publicPath }, resolve: { + // allows importing from the 'src' folder + // to avoid having to type long relative paths to get back up the folder hierarchy + root: [ paths.appSrc ], // This allows you to set a fallback for where Webpack should look for modules. // We read `NODE_PATH` environment variable in `paths.js` and pass paths here. - // We use `fallback` instead of `root` because we want `node_modules` to "win" + // We use `fallback` because we want `node_modules` to "win" // if there any conflicts. This matches Node resolution mechanism. // https://github.com/facebookincubator/create-react-app/issues/253 fallback: paths.nodePaths, diff --git a/packages/react-scripts/utils/createJestConfig.js b/packages/react-scripts/utils/createJestConfig.js index df0238f2587..d792f5a8946 100644 --- a/packages/react-scripts/utils/createJestConfig.js +++ b/packages/react-scripts/utils/createJestConfig.js @@ -18,6 +18,7 @@ module.exports = (resolve, rootDir, isEjecting) => { const setupTestsFile = pathExists.sync(paths.testsSetup) ? '/src/setupTests.js' : undefined; const config = { + modulePaths: ['/src'], collectCoverageFrom: ['src/**/*.{js,jsx}'], moduleFileExtensions: ['jsx', 'js', 'json'], moduleNameMapper: { From 7a2059a2828532139f95e48356a187a2b0d39d81 Mon Sep 17 00:00:00 2001 From: Alpha Shuro Date: Tue, 15 Nov 2016 21:25:20 +0200 Subject: [PATCH 2/2] fix tab --- packages/react-scripts/utils/createJestConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/utils/createJestConfig.js b/packages/react-scripts/utils/createJestConfig.js index d792f5a8946..d84b99be7a9 100644 --- a/packages/react-scripts/utils/createJestConfig.js +++ b/packages/react-scripts/utils/createJestConfig.js @@ -18,7 +18,7 @@ module.exports = (resolve, rootDir, isEjecting) => { const setupTestsFile = pathExists.sync(paths.testsSetup) ? '/src/setupTests.js' : undefined; const config = { - modulePaths: ['/src'], + modulePaths: ['/src'], collectCoverageFrom: ['src/**/*.{js,jsx}'], moduleFileExtensions: ['jsx', 'js', 'json'], moduleNameMapper: {