From 8541005028ab17bcffcc9def14c4ad0cf416ee43 Mon Sep 17 00:00:00 2001 From: Rabbit Date: Fri, 17 Nov 2017 10:19:14 +0800 Subject: [PATCH 1/2] Add sourceMap source mapping function. --- lib/loader.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/loader.js b/lib/loader.js index cb8ff307..c98f82f7 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -115,7 +115,9 @@ module.exports = function(content, map) { map = result.map; if(map.sources) { map.sources = map.sources.map(function(source) { - return source.split("!").pop().replace(/\\/g, '/'); + const output = source.split("!").pop().replace(/\\/g, '/'); + if(!query.sourceMapSourcesMapping) return output + return query.sourceMapSourcesMapping(output) }, this); map.sourceRoot = ""; } From 219a054b4f292d9324d6936937a9adcf29a5c22a Mon Sep 17 00:00:00 2001 From: Rabbit Date: Fri, 17 Nov 2017 11:08:14 +0800 Subject: [PATCH 2/2] Fix bug --- lib/loader.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/loader.js b/lib/loader.js index c98f82f7..158a209b 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -115,9 +115,13 @@ module.exports = function(content, map) { map = result.map; if(map.sources) { map.sources = map.sources.map(function(source) { - const output = source.split("!").pop().replace(/\\/g, '/'); - if(!query.sourceMapSourcesMapping) return output - return query.sourceMapSourcesMapping(output) + return (query.sourceMapSourcesDomain || '') + + source.split("!") + .pop() + .replace(/\\/g, '/') + .replace(/(\w):\//, function(_, id) { + return id.toUpperCase() + ':\/'; + }); }, this); map.sourceRoot = ""; }