Commit 1e3a64fa authored by Ade Viankakrisna Fadlil's avatar Ade Viankakrisna Fadlil Committed by Joe Haddad
Browse files

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
parent badfc2a8
3 merge requests!12191Lim.Pisey.168:/Identified - We are currently investigating reports of missing build logs. The issue has been identified and a resolution is in progress. We will provide a further update when available.Mar 21, 09:02 UTC,!12853brikk,!5717Automatically extract project file structure from build bundle file
Showing with 5 additions and 3 deletions
+5 -3
...@@ -29,6 +29,8 @@ const publicPath = paths.servedPath; ...@@ -29,6 +29,8 @@ const publicPath = paths.servedPath;
// Some apps do not use client-side routing with pushState. // Some apps do not use client-side routing with pushState.
// For these, "homepage" can be set to "." to enable relative asset paths. // For these, "homepage" can be set to "." to enable relative asset paths.
const shouldUseRelativeAssetPaths = publicPath === './'; 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 // `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. // 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. // Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
...@@ -62,7 +64,7 @@ module.exports = { ...@@ -62,7 +64,7 @@ module.exports = {
bail: true, bail: true,
// We generate sourcemaps in production. This is slow but gives good results. // We generate sourcemaps in production. This is slow but gives good results.
// You can exclude the *.map files from the build during deployment. // 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. // In production, we only want to load the polyfills and the app code.
entry: [require.resolve('./polyfills'), paths.appIndexJs], entry: [require.resolve('./polyfills'), paths.appIndexJs],
output: { output: {
...@@ -204,7 +206,7 @@ module.exports = { ...@@ -204,7 +206,7 @@ module.exports = {
options: { options: {
importLoaders: 1, importLoaders: 1,
minimize: true, minimize: true,
sourceMap: true, sourceMap: shouldUseSourceMap,
}, },
}, },
{ {
...@@ -300,7 +302,7 @@ module.exports = { ...@@ -300,7 +302,7 @@ module.exports = {
// https://github.com/facebookincubator/create-react-app/issues/2488 // https://github.com/facebookincubator/create-react-app/issues/2488
ascii_only: true, ascii_only: true,
}, },
sourceMap: true, sourceMap: shouldUseSourceMap,
}), }),
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`. // Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
new ExtractTextPlugin({ new ExtractTextPlugin({
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment