Skip to content

Commit 159b66a

Browse files
fix(index): don't fail on 'sourceMap: false' && emit a warning instead, when previous map found (options.sourceMap)
1 parent fbef238 commit 159b66a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,12 @@ module.exports = function loader (css, map) {
127127
css = this.exec(css, this.resource)
128128
}
129129

130-
if (typeof map === 'string') map = JSON.parse(map)
131-
if (map && map.mappings) options.map.prev = map
130+
if (!sourceMap && map) {
131+
this.emitWarning(`\n\n ⚠️ PostCSS Loader\n\nPrevious source map found, but options.sourceMap isn't set, this way the loader will discard the source map enterily for performance reasons, see https://github.com/postcss/postcss-loader#sourcemap for more info on the subject\n\n`)
132+
}
133+
134+
if (sourceMap && typeof map === 'string') map = JSON.parse(map)
135+
if (sourceMap && map) options.map.prev = map
132136

133137
return postcss(plugins)
134138
.process(css, options)

0 commit comments

Comments
 (0)