Skip to content

Commit f527592

Browse files
viankakrisnaswengorschewski
authored andcommittedOct 12, 2017
Use env variable to disable source maps (#2818)
* use env variable to disable source maps * Rename to use SOURCE_MAP with explicit value * Update webpack.config.prod.js
1 parent d231f57 commit f527592

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const publicPath = paths.servedPath;
2828
// Some apps do not use client-side routing with pushState.
2929
// For these, "homepage" can be set to "." to enable relative asset paths.
3030
const shouldUseRelativeAssetPaths = publicPath === './';
31+
// Source maps are resource heavy and can cause out of memory issue for large source files.
32+
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
3133
// `publicUrl` is just like `publicPath`, but we will provide it to our app
3234
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
3335
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
@@ -61,7 +63,7 @@ module.exports = {
6163
bail: true,
6264
// We generate sourcemaps in production. This is slow but gives good results.
6365
// You can exclude the *.map files from the build during deployment.
64-
devtool: 'source-map',
66+
devtool: shouldUseSourceMap ? 'source-map' : false,
6567
target: 'electron-renderer',
6668
// In production, we only want to load the polyfills and the app code.
6769
entry: [require.resolve('./polyfills'), paths.appIndexJs],
@@ -196,7 +198,7 @@ module.exports = {
196198
options: {
197199
importLoaders: 1,
198200
minimize: true,
199-
sourceMap: true,
201+
sourceMap: shouldUseSourceMap,
200202
},
201203
},
202204
{
@@ -292,7 +294,7 @@ module.exports = {
292294
// https://github.com/facebookincubator/create-react-app/issues/2488
293295
ascii_only: true,
294296
},
295-
sourceMap: true,
297+
sourceMap: shouldUseSourceMap,
296298
}),
297299
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
298300
new ExtractTextPlugin({

0 commit comments

Comments
 (0)
Please sign in to comment.