Skip to content

Commit

Permalink
Merge pull request #693 from stealjs/clean-css-rebase
Browse files Browse the repository at this point in the history
Prevent clean-css to rebase urls
  • Loading branch information
matthewp committed May 4, 2017
2 parents a42063f + 1c3bc69 commit 3eb9d6c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/assign_default_options.js
Expand Up @@ -12,6 +12,7 @@ module.exports = function(config, options){
bundleSteal: false,
uglifyOptions: {},
cleanCSSOptions: {
rebase: false,
inline: ["none"]
},
removeDevelopmentCode: true,
Expand Down
1 change: 1 addition & 0 deletions test/css_image_urls/foo.js
@@ -0,0 +1 @@
require("./main.css");
1 change: 1 addition & 0 deletions test/css_image_urls/main.css
@@ -0,0 +1 @@
.topbanner { background-image: url("../../../topbanner.png"); }
1 change: 1 addition & 0 deletions test/css_image_urls/main.js
@@ -0,0 +1 @@
require("./main.css");
8 changes: 8 additions & 0 deletions test/css_image_urls/stealconfig.js
@@ -0,0 +1,8 @@
steal.config({
ext: {
"css": "steal-css"
},
paths: {
"steal-css": "../steal-css.js"
}
});
25 changes: 25 additions & 0 deletions test/multibuild_test.js
Expand Up @@ -6,6 +6,7 @@ var multiBuild = require("../lib/build/multi");
var rmdir = require("rimraf");
var path = require("path");
var testHelpers = require("./helpers");
var _escapeRegExp = require("lodash/escapeRegExp");

var find = testHelpers.find;
var open = testHelpers.open;
Expand Down Expand Up @@ -2147,6 +2148,7 @@ describe("multi build", function(){
return multiBuild({
main: "bundle",
config: path.join(__dirname, "bundle", "stealconfig.js")

}, {
quiet: true
});
Expand All @@ -2166,4 +2168,27 @@ describe("multi build", function(){
"node name comment is removed when the bundle is minified");
});
});

it("clean-css should not rebase urls by default", function() {
var base = path.join(__dirname, "css_image_urls");

return asap(rmdir)(path.join(base, "dist"))
.then(function() {
return multiBuild({
main: "main",
config: path.join(base, "stealconfig.js")
}, {
quiet: true
});
})
.then(function() {
return asap(fs.readFile)(
path.join(base, "dist", "bundles", "main.css")
);
})
.then(function(source) {
var rx = new RegExp(_escapeRegExp("url(../../../../../topbanner.png)"));
assert.ok(rx.test(source), "image url should be relative to 'dist'");
});
});
});

0 comments on commit 3eb9d6c

Please sign in to comment.