Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add quickfix for csso parse error
  • Loading branch information
jhnns committed Feb 3, 2015
commit 3afe7f872deecf747f659776f3708b1a42542a3f
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function(content, map) {
var forceMinimize = query.minimize;
var importLoaders = parseInt(query.importLoaders, 10) || 0;
var minimize = typeof forceMinimize !== "undefined" ? !!forceMinimize : (this && this.minimize);
var tree = csso.parse(content, "stylesheet");
var tree = csso.parse(prepareContentForCsso(content), "stylesheet");
if(tree && minimize) {
tree = csso.compress(tree, query.disableStructuralMinification);
tree = csso.cleanInfo(tree);
Expand Down Expand Up @@ -161,4 +161,9 @@ function annotateUrls(tree) {
}
}
}

// Quickfix for https://github.com/webpack/css-loader/issues/36
// Remove this test when the problem has been fixed at https://github.com/css/csso/issues/185
// or when another css parser is used
function prepareContentForCsso(content) {
return content.replace(/\*\/\w*@/g, "*/a{}@");
}
9 changes: 9 additions & 0 deletions test/urlTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ describe("url", function() {
test("media query", "@media (min-width: 500px) { body { background: url(image.png); } }", [
[1, "@media (min-width: 500px) { body { background: url({./image.png}); } }", ""]
]);
// Quickfix for https://github.com/webpack/css-loader/issues/36
// Remove this test when the problem has been fixed at https://github.com/css/csso/issues/185
// or when another css parser is used
test("csso parse error", "/**/@import url(test.css);", [
[2, ".test{a: b}", ""],
[1, "/**/a{}", ""]
], "", {
"./test.css": [[2, ".test{a: b}", ""]]
});
testMinimize("minimized simple", ".class { a: b c d; }", [
[1, ".class{a:b c d}", ""]
]);
Expand Down