From: GoalSmashers Date: Wed, 23 Oct 2013 14:19:33 +0000 (+0200) Subject: Fixes #152 - adds a `--skip-rebase` / noRebase option to disable URL rebasing altogether. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=59430842e11dd07081c0e435d776ec8cde14404c;p=clean-css.git Fixes #152 - adds a `--skip-rebase` / noRebase option to disable URL rebasing altogether. --- diff --git a/History.md b/History.md index 68166d88..91fe3f04 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,11 @@ * Adds simplified and more advanced text escaping / restoring via EscapeStore class. +1.1.4 / 2013-xx-xx (UNRELEASED) +================== + +* Fixed issue [#152](https://github.com/GoalSmashers/clean-css/issues/152) - adds an option to disable rebasing. + 1.1.3 / 2013-10-04 ================== diff --git a/README.md b/README.md index 6a97ccb2..e03a1210 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,8 @@ cleancss [options] --s1 Remove all special comments but the first one -r, --root [root-path] A root path to which resolve absolute @import rules and rebase relative URLs -o, --output [output-file] Use [output-file] as output instead of STDOUT --s, --skip-import Disable the @import processing +-s, --skip-import Disable @import processing +--skip-rebase Disable URLs rebasing -d, --debug Shows debug information (minification time & compression efficiency) ``` @@ -95,6 +96,7 @@ Process method accepts a hash as a second parameter, i.e., * `root` - path to resolve absolute `@import` rules and rebase relative URLs * `relativeTo` - path with which to resolve relative `@import` rules and URLs * `processImport` - whether to process `@import` rules +* `noRebase` - whether to skip URLs rebasing ### What are the clean-css' dev commands? diff --git a/bin/cleancss b/bin/cleancss index 89521e4e..5b3ed7d5 100755 --- a/bin/cleancss +++ b/bin/cleancss @@ -22,7 +22,8 @@ commands .option('--s1', 'Remove all special comments but the first one') .option('-r, --root [root-path]', 'Set a root path to which resolve absolute @import rules') .option('-o, --output [output-file]', 'Use [output-file] as output instead of STDOUT') - .option('-s, --skip-import', 'Disable the @import processing') + .option('-s, --skip-import', 'Disable @import processing') + .option('--skip-rebase', 'Disable URLs rebasing') .option('-d, --debug', 'Shows debug information (minification time & compression efficiency)'); commands.on('--help', function() { @@ -69,6 +70,8 @@ if (commands.root) cleanOptions.root = commands.root; if (commands.skipImport) cleanOptions.processImport = false; +if (commands.skipRebase) + cleanOptions.noRebase = true; if (commands.debug) options.debug = true; if (commands.args.length > 0) { diff --git a/lib/clean.js b/lib/clean.js index 89292334..7e1a9c2a 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -243,7 +243,7 @@ var CleanCSS = { data = urlsProcessor.restore(data); }); replace(function rebaseUrls() { - data = UrlRebase.process(data, options); + data = options.noRebase ? data : UrlRebase.process(data, options); }); replace(function restoreFreeText() { data = freeTextProcessor.restore(data); diff --git a/test/binary-test.js b/test/binary-test.js index 2d132cfa..e1d34341 100644 --- a/test/binary-test.js +++ b/test/binary-test.js @@ -207,5 +207,15 @@ exports.commandsSuite = vows.describe('binary commands').addBatch({ deleteFile('./test/data/129-assets/assets/ui.bundled.css'); } }) + }, + 'complex import and skipped url rebasing': { + absolute: binaryContext('-r ./test/data/129-assets --skip-rebase ./test/data/129-assets/assets/ui.css', { + 'should rebase urls correctly': function(error, stdout) { + assert.equal(error, null); + assert.include(stdout, 'url(../components/bootstrap/images/glyphs.gif)'); + assert.include(stdout, 'url(../components/jquery-ui/images/prev.gif)'); + assert.include(stdout, 'url(../components/jquery-ui/images/next.gif)'); + } + }) } });