Skip to content

Commit

Permalink
fix: source maps path on windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed May 12, 2017
1 parent 3608136 commit 73d9876
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/loader.js
Expand Up @@ -21,7 +21,7 @@ module.exports = function(content, map) {

if(sourceMap) {
if (map) {
if (typeof map !== "string") {
if (typeof map === "string") {
map = JSON.stringify(map);
}

Expand Down
30 changes: 28 additions & 2 deletions test/sourceMapTest.js
Expand Up @@ -10,7 +10,7 @@ describe("source maps", function() {
testWithMap("falsy: undefined map doesn't cause an error", ".class { a: b c d; }", undefined, [
[1, ".class { a: b c d; }", ""]
]);
testWithMap("should don't generate sourceMap when `sourceMap: false` and map exist",
testWithMap("should don't generate sourceMap when `sourceMap: false` and map exists",
".class { a: b c d; }",
{
file: 'test.css',
Expand All @@ -28,7 +28,7 @@ describe("source maps", function() {
sourceMap: false
}
);
testWithMap("should don't generate sourceMap when `sourceMap: true` and map exist",
testWithMap("should don't generate sourceMap when `sourceMap: true` and map exists",
".class { a: b c d; }",
{
file: 'test.css',
Expand All @@ -54,6 +54,32 @@ describe("source maps", function() {
sourceMap: true
}
);
testWithMap("should don't generate sourceMap when `sourceMap: true` and map exists and string",
".class { a: b c d; }",
JSON.stringify({
file: 'test.css',
mappings: 'AAAA,SAAS,SAAS,EAAE',
names: [],
sourceRoot: '',
sources: [ '/folder/test.css' ],
sourcesContent: [ '.class { a: b c d; }' ],
version: 3
}),
[
[1, ".class { a: b c d; }", "", {
file: 'test.css',
mappings: 'AAAA,SAAS,SAAS,EAAE',
names: [],
sourceRoot: '',
sources: [ '/folder/test.css' ],
sourcesContent: [ '.class { a: b c d; }' ],
version: 3
}]
],
{
sourceMap: true
}
);
testMap("generate sourceMap (1 loader)", ".class { a: b c d; }", undefined, {
loaders: [{request: "/path/css-loader"}],
resource: "/folder/test.css",
Expand Down

0 comments on commit 73d9876

Please sign in to comment.