diff --git a/lib/loader.js b/lib/loader.js index f4d0d98e..884e6f21 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -97,10 +97,14 @@ module.exports = function(content, map) { map = result.map; if(map.sources) { map.sources = map.sources.map(function(source) { - var p = path.relative(query.context || this.options.context, source).replace(/\\/g, "/"); - if(p.indexOf("../") !== 0) - p = "./" + p; - return "/" + p; + // trim off everything until the last occurrence of context + // we don't need the loader stuff in CSS source map sources. + var context = query.context || this.options.context; + var i = source.lastIndexOf(context); + if (i > -1) { + source = source.slice(i + context.length); + } + return "/" + source; }, this); map.sourceRoot = "webpack://"; }