Skip to content

Commit c769ac3

Browse files
brokenmassjoshwiens
authored andcommitted
fix(sourcemaps): use abs paths & remove sourceRoot
1 parent d7317ca commit c769ac3

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

lib/loader.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
var path = require("path");
65
var loaderUtils = require("loader-utils");
76
var processCss = require("./processCss");
87
var getImportPrefix = require("./getImportPrefix");
@@ -97,13 +96,9 @@ module.exports = function(content, map) {
9796
map = result.map;
9897
if(map.sources) {
9998
map.sources = map.sources.map(function(source) {
100-
source = source.split("!").pop();
101-
var p = path.relative(query.context || this.options.context, source).replace(/\\/g, "/");
102-
if(p.indexOf("../") !== 0)
103-
p = "./" + p;
104-
return "/" + p;
99+
return source.split("!").pop();
105100
}, this);
106-
map.sourceRoot = "webpack://";
101+
map.sourceRoot = "";
107102
}
108103
map.file = map.file.split("!").pop();
109104
map = JSON.stringify(map);

test/sourceMapTest.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ describe("source maps", function() {
2121
file: 'test.css',
2222
mappings: 'AAAA,SAAS,SAAS,EAAE',
2323
names: [],
24-
sourceRoot: 'webpack://',
25-
sources: [ '/./folder/test.css' ],
24+
sourceRoot: '',
25+
sources: [ '/folder/test.css' ],
2626
sourcesContent: [ '.class { a: b c d; }' ],
2727
version: 3
2828
}]
@@ -38,8 +38,8 @@ describe("source maps", function() {
3838
file: 'test.css',
3939
mappings: 'AAAA,SAAS,SAAS,EAAE',
4040
names: [],
41-
sourceRoot: 'webpack://',
42-
sources: [ '/../../folder/test.css' ],
41+
sourceRoot: '',
42+
sources: [ '/folder/test.css' ],
4343
sourcesContent: [ '.class { a: b c d; }' ],
4444
version: 3
4545
}]
@@ -55,8 +55,8 @@ describe("source maps", function() {
5555
file: 'test.scss',
5656
mappings: 'AAAA,SAAS,SAAS,EAAE',
5757
names: [],
58-
sourceRoot: 'webpack://',
59-
sources: [ '/./folder/test.scss' ],
58+
sourceRoot: '',
59+
sources: [ '/folder/test.scss' ],
6060
sourcesContent: [ '.class { a: b c d; }' ],
6161
version: 3
6262
}]

0 commit comments

Comments
 (0)