From d5b370d8abb6f187a8e901f5673a8146050f9bb8 Mon Sep 17 00:00:00 2001 From: dawidboruta Date: Sat, 13 Jan 2018 19:30:58 +0100 Subject: [PATCH] Fixed problem with tsconfig.json baseUrl and paths --- packages/react-scripts/config/webpack.config.dev.js | 2 ++ packages/react-scripts/config/webpack.config.prod.js | 2 ++ packages/react-scripts/package.json | 1 + 3 files changed, 5 insertions(+) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 6c619f4f4..269a18ad6 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -21,6 +21,7 @@ const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin'); const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); const getClientEnvironment = require('./env'); const paths = require('./paths'); +const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); // Webpack uses `publicPath` to determine where the app is being served from. // In development, we always serve from the root. This makes config easier. @@ -126,6 +127,7 @@ module.exports = { // please link the files into your node_modules/ and let module-resolution kick in. // Make sure your source files are compiled, as they will not be processed in any way. new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]), + new TsconfigPathsPlugin({configFile: paths.appTsConfig}) ], }, module: { diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 366dcd108..a18869245 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -22,6 +22,7 @@ const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin'); const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); const paths = require('./paths'); const getClientEnvironment = require('./env'); +const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); // Webpack uses `publicPath` to determine where the app is being served from. // It requires a trailing slash, or the file assets will get an incorrect path. @@ -130,6 +131,7 @@ module.exports = { // please link the files into your node_modules/ and let module-resolution kick in. // Make sure your source files are compiled, as they will not be processed in any way. new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]), + new TsconfigPathsPlugin({configFile: paths.appTsConfig}) ], }, module: { diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 648e0956e..f8f6fe79c 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -40,6 +40,7 @@ "style-loader": "0.18.2", "ts-jest": "^20.0.7", "ts-loader": "^2.3.7", + "tsconfig-paths-webpack-plugin": "^2.0.0", "tslint": "^5.7.0", "tslint-loader": "^3.5.3", "tslint-react": "^3.2.0",