@@ -33,6 +33,10 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
33
33
const entryPoints : { [ key : string ] : string [ ] } = { } ;
34
34
const globalStylePaths : string [ ] = [ ] ;
35
35
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 ;
36
40
37
41
// discard comments in production
38
42
const extraPostCssPlugins = buildOptions . target === 'production'
@@ -75,7 +79,7 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
75
79
// so we need to add options in its query
76
80
{
77
81
test : / \. s t y l $ / , loaders : [ `stylus-loader?${ JSON . stringify ( {
78
- sourceMap : buildOptions . sourcemap ,
82
+ sourceMap : cssSourceMap ,
79
83
paths : includePaths
80
84
} ) } `]
81
85
}
@@ -95,7 +99,7 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
95
99
loader : [
96
100
// css-loader doesn't support webpack.LoaderOptionsPlugin properly,
97
101
// so we need to add options in its query
98
- `css-loader?${ JSON . stringify ( { sourceMap : buildOptions . sourcemap } ) } ` ,
102
+ `css-loader?${ JSON . stringify ( { sourceMap : cssSourceMap } ) } ` ,
99
103
...commonLoaders ,
100
104
...loaders
101
105
] ,
@@ -121,14 +125,14 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
121
125
disable : ! buildOptions . extractCss
122
126
} ) ,
123
127
new webpack . LoaderOptionsPlugin ( {
124
- sourceMap : true ,
128
+ sourceMap : cssSourceMap ,
125
129
options : {
126
130
postcss : [ autoprefixer ( ) ] . concat ( extraPostCssPlugins ) ,
127
131
// css-loader, stylus-loader don't support LoaderOptionsPlugin properly
128
132
// options are in query instead
129
- sassLoader : { sourceMap : buildOptions . sourcemap , includePaths } ,
133
+ sassLoader : { sourceMap : cssSourceMap , includePaths } ,
130
134
// less-loader doesn't support paths
131
- lessLoader : { sourceMap : buildOptions . sourcemap } ,
135
+ lessLoader : { sourceMap : cssSourceMap } ,
132
136
// context needed as a workaround https://github.com/jtangelder/sass-loader/issues/285
133
137
context : projectRoot ,
134
138
} ,
0 commit comments