From 8da2c723566c86425eb389fce46bc99bbeece4a9 Mon Sep 17 00:00:00 2001 From: Johannes Ewald Date: Wed, 30 Sep 2015 02:45:55 +0200 Subject: [PATCH] Fix confusing paths in source maps We don't need the loader stuff in CSS source map sources --- lib/loader.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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://"; }