Fixes #152 - adds a `--skip-rebase` / noRebase option to disable URL rebasing altogether.
authorGoalSmashers <jakub@goalsmashers.com>
Wed, 23 Oct 2013 14:19:33 +0000 (16:19 +0200)
committerGoalSmashers <jakub@goalsmashers.com>
Wed, 23 Oct 2013 14:25:45 +0000 (16:25 +0200)
History.md
README.md
bin/cleancss
lib/clean.js
test/binary-test.js

index 68166d8..91fe3f0 100644 (file)
@@ -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
 ==================
 
index 6a97ccb..e03a121 100644 (file)
--- a/README.md
+++ b/README.md
@@ -39,7 +39,8 @@ cleancss [options] <source-file>
 --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?
 
index 89521e4..5b3ed7d 100755 (executable)
@@ -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) {
index 8929233..7e1a9c2 100644 (file)
@@ -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);
index 2d132cf..e1d3434 100644 (file)
@@ -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)');
+      }
+    })
   }
 });