From 835f8743de917ecf6c9fa5afee30a8b86610a174 Mon Sep 17 00:00:00 2001 From: Justin Grant Date: Sun, 29 Nov 2020 21:55:07 -0800 Subject: [PATCH] build: add source-map-loader to webpack config --- .../react-scripts/config/webpack.config.js | 9 ++++++++- packages/react-scripts/package.json | 1 + packages/react-scripts/scripts/build.js | 18 +++++++++++------- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index 5e5f87f3ce9..c0f66cb1bd4 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -374,6 +374,13 @@ module.exports = function (webpackEnv) { rules: [ // Disable require.ensure as it's not a standard language feature. { parser: { requireEnsure: false } }, + // Handle node_modules packages that contain sourcemaps + shouldUseSourceMap && { + enforce: 'pre', + exclude: /@babel(?:\/|\\{1,2})runtime/, + test: /\.(js|mjs|jsx|ts|tsx|css)$/, + use: 'source-map-loader', + }, { // "oneOf" will traverse all following loaders until one will // match the requirements. When no loader matches it will fall @@ -605,7 +612,7 @@ module.exports = function (webpackEnv) { // Make sure to add the new loader(s) before the "file" loader. ], }, - ], + ].filter(Boolean), }, plugins: [ // Generates an `index.html` file with the