From 34181754397dcb52f3e8b9b470d70f1def42838a Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil Date: Mon, 17 Jul 2017 08:23:23 +0700 Subject: [PATCH 1/3] use env variable to disable source maps --- packages/react-scripts/config/webpack.config.prod.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 0077c34a3f6..2d3af202a82 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -29,6 +29,8 @@ const publicPath = paths.servedPath; // Some apps do not use client-side routing with pushState. // For these, "homepage" can be set to "." to enable relative asset paths. const shouldUseRelativeAssetPaths = publicPath === './'; +// Source maps are resource heavy and can cause out of memory issue for large source files. +const shouldUseSourceMap = !process.env.REACT_APP_DISABLE_SOURCE_MAP; // `publicUrl` is just like `publicPath`, but we will provide it to our app // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript. // Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz. @@ -62,7 +64,7 @@ module.exports = { bail: true, // We generate sourcemaps in production. This is slow but gives good results. // You can exclude the *.map files from the build during deployment. - devtool: 'source-map', + devtool: shouldUseSourceMap ? 'source-map' : false, // In production, we only want to load the polyfills and the app code. entry: [require.resolve('./polyfills'), paths.appIndexJs], output: { @@ -204,7 +206,7 @@ module.exports = { options: { importLoaders: 1, minimize: true, - sourceMap: true, + sourceMap: shouldUseSourceMap, }, }, { @@ -300,7 +302,7 @@ module.exports = { // https://github.com/facebookincubator/create-react-app/issues/2488 ascii_only: true, }, - sourceMap: true, + sourceMap: shouldUseSourceMap, }), // Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`. new ExtractTextPlugin({ From 83b3a6f787efb5c19e3aac83c4b1292820d3f8b9 Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil Date: Wed, 2 Aug 2017 20:34:52 +0700 Subject: [PATCH 2/3] Rename to use SOURCE_MAP with explicit value --- packages/react-scripts/config/webpack.config.prod.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 2d3af202a82..9ceb0bccace 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -30,7 +30,7 @@ const publicPath = paths.servedPath; // For these, "homepage" can be set to "." to enable relative asset paths. const shouldUseRelativeAssetPaths = publicPath === './'; // Source maps are resource heavy and can cause out of memory issue for large source files. -const shouldUseSourceMap = !process.env.REACT_APP_DISABLE_SOURCE_MAP; +const shouldUseSourceMap = process.env.SOURCE_MAP !== 'false'; // `publicUrl` is just like `publicPath`, but we will provide it to our app // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript. // Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz. From 56805e56b5deb274ad1c71c70231e3b126475012 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Tue, 8 Aug 2017 21:53:17 -0400 Subject: [PATCH 3/3] Update webpack.config.prod.js --- packages/react-scripts/config/webpack.config.prod.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 9ceb0bccace..a38f734fe06 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -30,7 +30,7 @@ const publicPath = paths.servedPath; // For these, "homepage" can be set to "." to enable relative asset paths. const shouldUseRelativeAssetPaths = publicPath === './'; // Source maps are resource heavy and can cause out of memory issue for large source files. -const shouldUseSourceMap = process.env.SOURCE_MAP !== 'false'; +const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false'; // `publicUrl` is just like `publicPath`, but we will provide it to our app // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript. // Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.