@@ -33,6 +33,10 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
3333 const entryPoints : { [ key : string ] : string [ ] } = { } ;
3434 const globalStylePaths : string [ ] = [ ] ;
3535 const extraPlugins : any [ ] = [ ] ;
36+ // style-loader does not support sourcemaps without absolute publicPath, so it's
37+ // better to disable them when not extracting css
38+ // https://github.com/webpack-contrib/style-loader#recommended-configuration
39+ const cssSourceMap = buildOptions . extractCss && buildOptions . sourcemap ;
3640
3741 // discard comments in production
3842 const extraPostCssPlugins = buildOptions . target === 'production'
@@ -75,7 +79,7 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
7579 // so we need to add options in its query
7680 {
7781 test : / \. s t y l $ / , loaders : [ `stylus-loader?${ JSON . stringify ( {
78- sourceMap : buildOptions . sourcemap ,
82+ sourceMap : cssSourceMap ,
7983 paths : includePaths
8084 } ) } `]
8185 }
@@ -95,7 +99,7 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
9599 loader : [
96100 // css-loader doesn't support webpack.LoaderOptionsPlugin properly,
97101 // so we need to add options in its query
98- `css-loader?${ JSON . stringify ( { sourceMap : buildOptions . sourcemap } ) } ` ,
102+ `css-loader?${ JSON . stringify ( { sourceMap : cssSourceMap } ) } ` ,
99103 ...commonLoaders ,
100104 ...loaders
101105 ] ,
@@ -121,14 +125,14 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
121125 disable : ! buildOptions . extractCss
122126 } ) ,
123127 new webpack . LoaderOptionsPlugin ( {
124- sourceMap : true ,
128+ sourceMap : cssSourceMap ,
125129 options : {
126130 postcss : [ autoprefixer ( ) ] . concat ( extraPostCssPlugins ) ,
127131 // css-loader, stylus-loader don't support LoaderOptionsPlugin properly
128132 // options are in query instead
129- sassLoader : { sourceMap : buildOptions . sourcemap , includePaths } ,
133+ sassLoader : { sourceMap : cssSourceMap , includePaths } ,
130134 // less-loader doesn't support paths
131- lessLoader : { sourceMap : buildOptions . sourcemap } ,
135+ lessLoader : { sourceMap : cssSourceMap } ,
132136 // context needed as a workaround https://github.com/jtangelder/sass-loader/issues/285
133137 context : projectRoot ,
134138 } ,
0 commit comments