Skip to content

Commit

Permalink
Fixed: generate source maps when they are actually requested.
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Apr 26, 2017
1 parent 20ab625 commit cb1ceb3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions lib/loader.js
Expand Up @@ -19,10 +19,12 @@ module.exports = function(content, map) {
var sourceMap = query.sourceMap || false;
var resolve = createResolver(query.alias);

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

Expand All @@ -32,7 +34,8 @@ module.exports = function(content, map) {
to: loaderUtils.getCurrentRequest(this),
query: query,
minimize: this.minimize,
loaderContext: this
loaderContext: this,
sourceMap: sourceMap
}, function(err, result) {
if(err) return callback(err);

Expand Down
4 changes: 2 additions & 2 deletions lib/processCss.js
Expand Up @@ -200,12 +200,12 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
// we need a prefix to avoid path rewriting of PostCSS
from: "/css-loader!" + options.from,
to: options.to,
map: {
map: options.sourceMap ? {
prev: inputMap,
sourcesContent: true,
inline: false,
annotation: false
}
} : null
}).then(function(result) {
callback(null, {
source: result.css,
Expand Down

0 comments on commit cb1ceb3

Please sign in to comment.