Skip to content

Commit

Permalink
Use env variable to disable source maps (#2818)
Browse files Browse the repository at this point in the history
* use env variable to disable source maps

* Rename to use SOURCE_MAP with explicit value

* Update webpack.config.prod.js
  • Loading branch information
viankakrisna authored and swengorschewski committed Oct 12, 2017
1 parent d231f57 commit f527592
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/react-scripts/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,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.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.
Expand Down Expand Up @@ -61,7 +63,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,
target: 'electron-renderer',
// In production, we only want to load the polyfills and the app code.
entry: [require.resolve('./polyfills'), paths.appIndexJs],
Expand Down Expand Up @@ -196,7 +198,7 @@ module.exports = {
options: {
importLoaders: 1,
minimize: true,
sourceMap: true,
sourceMap: shouldUseSourceMap,
},
},
{
Expand Down Expand Up @@ -292,7 +294,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({
Expand Down

0 comments on commit f527592

Please sign in to comment.