Skip to content

Commit

Permalink
fix(sourcemaps): use abs paths & remove sourceRoot
Browse files Browse the repository at this point in the history
  • Loading branch information
brokenmass authored and joshwiens committed Mar 9, 2017
1 parent d7317ca commit c769ac3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
9 changes: 2 additions & 7 deletions lib/loader.js
Expand Up @@ -2,7 +2,6 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var path = require("path");
var loaderUtils = require("loader-utils");
var processCss = require("./processCss");
var getImportPrefix = require("./getImportPrefix");
Expand Down Expand Up @@ -97,13 +96,9 @@ module.exports = function(content, map) {
map = result.map;
if(map.sources) {
map.sources = map.sources.map(function(source) {
source = source.split("!").pop();
var p = path.relative(query.context || this.options.context, source).replace(/\\/g, "/");
if(p.indexOf("../") !== 0)
p = "./" + p;
return "/" + p;
return source.split("!").pop();
}, this);
map.sourceRoot = "webpack://";
map.sourceRoot = "";
}
map.file = map.file.split("!").pop();
map = JSON.stringify(map);
Expand Down
12 changes: 6 additions & 6 deletions test/sourceMapTest.js
Expand Up @@ -21,8 +21,8 @@ describe("source maps", function() {
file: 'test.css',
mappings: 'AAAA,SAAS,SAAS,EAAE',
names: [],
sourceRoot: 'webpack://',
sources: [ '/./folder/test.css' ],
sourceRoot: '',
sources: [ '/folder/test.css' ],
sourcesContent: [ '.class { a: b c d; }' ],
version: 3
}]
Expand All @@ -38,8 +38,8 @@ describe("source maps", function() {
file: 'test.css',
mappings: 'AAAA,SAAS,SAAS,EAAE',
names: [],
sourceRoot: 'webpack://',
sources: [ '/../../folder/test.css' ],
sourceRoot: '',
sources: [ '/folder/test.css' ],
sourcesContent: [ '.class { a: b c d; }' ],
version: 3
}]
Expand All @@ -55,8 +55,8 @@ describe("source maps", function() {
file: 'test.scss',
mappings: 'AAAA,SAAS,SAAS,EAAE',
names: [],
sourceRoot: 'webpack://',
sources: [ '/./folder/test.scss' ],
sourceRoot: '',
sources: [ '/folder/test.scss' ],
sourcesContent: [ '.class { a: b c d; }' ],
version: 3
}]
Expand Down

0 comments on commit c769ac3

Please sign in to comment.