Skip to content

Commit cb1ceb3

Browse files
author
evilebottnawi
committed
Fixed: generate source maps when they are actually requested.
1 parent 20ab625 commit cb1ceb3

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Diff for: lib/loader.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ module.exports = function(content, map) {
1919
var sourceMap = query.sourceMap || false;
2020
var resolve = createResolver(query.alias);
2121

22-
if(sourceMap && map !== null && typeof map !== "string") {
23-
map = JSON.stringify(map);
22+
if(sourceMap) {
23+
if (map && typeof map !== "string") {
24+
map = JSON.stringify(map);
25+
}
2426
} else {
25-
// Some loaders (example `postcss-loader: 1`) always generate source map, we should remove their
27+
// Some loaders (example `"postcss-loader": "1.x.x"`) always generates source map, we should remove it
2628
map = null;
2729
}
2830

@@ -32,7 +34,8 @@ module.exports = function(content, map) {
3234
to: loaderUtils.getCurrentRequest(this),
3335
query: query,
3436
minimize: this.minimize,
35-
loaderContext: this
37+
loaderContext: this,
38+
sourceMap: sourceMap
3639
}, function(err, result) {
3740
if(err) return callback(err);
3841

Diff for: lib/processCss.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
200200
// we need a prefix to avoid path rewriting of PostCSS
201201
from: "/css-loader!" + options.from,
202202
to: options.to,
203-
map: {
203+
map: options.sourceMap ? {
204204
prev: inputMap,
205205
sourcesContent: true,
206206
inline: false,
207207
annotation: false
208-
}
208+
} : null
209209
}).then(function(result) {
210210
callback(null, {
211211
source: result.css,

0 commit comments

Comments
 (0)