Skip to content

Commit 92fc8d9

Browse files
author
evilebottnawi
committed
fix: source maps path on windows.
1 parent 3608136 commit 92fc8d9

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

lib/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = function(content, map) {
2121

2222
if(sourceMap) {
2323
if (map) {
24-
if (typeof map !== "string") {
24+
if (typeof map === "string") {
2525
map = JSON.stringify(map);
2626
}
2727

lib/processCss.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
4848
url = url.url;
4949
} else if(url.type === "string") {
5050
url = url.value;
51-
} else throw rule.error("Unexpected format" + rule.params);
51+
} else throw rule.error("Unexpected format " + rule.params);
5252
if (!url.replace(/\s/g, '').length) {
5353
return;
5454
}

test/sourceMapTest.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe("source maps", function() {
1010
testWithMap("falsy: undefined map doesn't cause an error", ".class { a: b c d; }", undefined, [
1111
[1, ".class { a: b c d; }", ""]
1212
]);
13-
testWithMap("should don't generate sourceMap when `sourceMap: false` and map exist",
13+
testWithMap("should don't generate sourceMap when `sourceMap: false` and map exists",
1414
".class { a: b c d; }",
1515
{
1616
file: 'test.css',
@@ -28,7 +28,7 @@ describe("source maps", function() {
2828
sourceMap: false
2929
}
3030
);
31-
testWithMap("should don't generate sourceMap when `sourceMap: true` and map exist",
31+
testWithMap("should don't generate sourceMap when `sourceMap: true` and map exists",
3232
".class { a: b c d; }",
3333
{
3434
file: 'test.css',
@@ -54,6 +54,32 @@ describe("source maps", function() {
5454
sourceMap: true
5555
}
5656
);
57+
testWithMap("should don't generate sourceMap when `sourceMap: true` and map exists and string",
58+
".class { a: b c d; }",
59+
JSON.stringify({
60+
file: 'test.css',
61+
mappings: 'AAAA,SAAS,SAAS,EAAE',
62+
names: [],
63+
sourceRoot: '',
64+
sources: [ '/folder/test.css' ],
65+
sourcesContent: [ '.class { a: b c d; }' ],
66+
version: 3
67+
}),
68+
[
69+
[1, ".class { a: b c d; }", "", {
70+
file: 'test.css',
71+
mappings: 'AAAA,SAAS,SAAS,EAAE',
72+
names: [],
73+
sourceRoot: '',
74+
sources: [ '/folder/test.css' ],
75+
sourcesContent: [ '.class { a: b c d; }' ],
76+
version: 3
77+
}]
78+
],
79+
{
80+
sourceMap: true
81+
}
82+
);
5783
testMap("generate sourceMap (1 loader)", ".class { a: b c d; }", undefined, {
5884
loaders: [{request: "/path/css-loader"}],
5985
resource: "/folder/test.css",

0 commit comments

Comments
 (0)