diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 7244ff79671..1822a6166c5 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -11,6 +11,7 @@ 'use strict'; const autoprefixer = require('autoprefixer'); +const path = require('path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); @@ -72,6 +73,9 @@ module.exports = { filename: 'static/js/bundle.js', // This is the URL that app is served from. We use "/" in development. publicPath: publicPath, + // Point sourcemap entries to original disk location + devtoolModuleFilenameTemplate: info => + path.relative(paths.appSrc, info.absoluteResourcePath), }, resolve: { // This allows you to set a fallback for where Webpack should look for modules. diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index a38a98e49ea..5210cffb1cf 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -11,6 +11,7 @@ 'use strict'; const autoprefixer = require('autoprefixer'); +const path = require('path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); @@ -71,6 +72,9 @@ module.exports = { chunkFilename: 'static/js/[name].[chunkhash:8].chunk.js', // We inferred the "public path" (such as / or /my-project) from homepage. publicPath: publicPath, + // Point sourcemap entries to original disk location + devtoolModuleFilenameTemplate: info => + path.relative(paths.appSrc, info.absoluteResourcePath), }, resolve: { // This allows you to set a fallback for where Webpack should look for modules.