Improves handling & documentation of minification options.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 10 Oct 2014 06:17:07 +0000 (07:17 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 10 Oct 2014 20:27:12 +0000 (21:27 +0100)
README.md
lib/clean.js

index 5f9df6f..d30bfef 100644 (file)
--- a/README.md
+++ b/README.md
@@ -121,19 +121,20 @@ var minimized = new CleanCSS().minify(source);
 CleanCSS constructor accepts a hash as a parameter, i.e.,
 `new CleanCSS(options).minify(source)` with the following options available:
 
-* `keepSpecialComments` - `*` for keeping all (default), `1` for keeping first one only, `0` for removing all
+* `benchmark` - turns on benchmarking mode measuring time spent on cleaning up (run `npm run bench` to see example)
+* `compatibility` - Force compatibility mode to `ie7` or `ie8`. Defaults to not set.
+* `debug` - set to true to get minification statistics under `stats` property (see `test/custom-test.js` for examples)
+* `inliner` - a hash of options for `@import` inliner, see test/protocol-imports-test.js for examples
 * `keepBreaks` - whether to keep line breaks (default is false)
-* `benchmark` - turns on benchmarking mode measuring time spent on cleaning up
-  (run `npm run bench` to see example)
-* `root` - path to __resolve__ absolute `@import` rules and __rebase__ relative URLs
-* `relativeTo` - path to __resolve__ relative `@import` rules and URLs
-* `target` - path to a folder or an output file to which __rebase__ all URLs
-* `processImport` - whether to process `@import` rules
-* `noRebase` - whether to skip URLs rebasing
+* `keepSpecialComments` - `*` for keeping all (default), `1` for keeping first one only, `0` for removing all
 * `noAdvanced` - set to true to disable advanced optimizations - selector & property merging, reduction, etc.
+* `noAggressiveMerging` - set to true to disable aggressive merging of properties.
+* `noRebase` - whether to skip URLs rebasing
+* `processImport` - whether to process `@import` rules
+* `relativeTo` - path to __resolve__ relative `@import` rules and URLs
+* `root` - path to __resolve__ absolute `@import` rules and __rebase__ relative URLs
 * `roundingPrecision` - Rounding precision, defaults to 2.
-* `compatibility` - Force compatibility mode to `ie7` or `ie8`. Defaults to not set.
-* `debug` - set to true to get minification statistics under `stats` property (see `test/custom-test.js` for examples)
+* `target` - path to a folder or an output file to which __rebase__ all URLs
 
 ### How to use clean-css with build tools?
 
index 3b7ba0b..ff72fc2 100644 (file)
@@ -17,13 +17,23 @@ var UrlsProcessor = require('./text/urls-processor');
 var CleanCSS = module.exports = function CleanCSS(options) {
   options = options || {};
 
-  options.keepBreaks = options.keepBreaks || false;
-
-  //active by default
-  if (undefined === options.processImport)
-    options.processImport = true;
+  this.options = {
+    benchmark: options.benchmark,
+    compatibility: options.compatibility,
+    debug: options.debug,
+    inliner: options.inliner,
+    keepBreaks: options.keepBreaks || false,
+    keepSpecialComments: 'keepSpecialComments' in options ? options.keepSpecialComments : '*',
+    noAdvanced: options.noAdvanced,
+    noAggressiveMerging: options.noAggressiveMerging,
+    noRebase: options.noRebase,
+    processImport: undefined === options.processImport ? true : false,
+    relativeTo: options.relativeTo,
+    root: options.root,
+    roundingPrecision: options.roundingPrecision,
+    target: options.target
+  };
 
-  this.options = options;
   this.stats = {};
   this.context = {
     errors: [],
@@ -100,7 +110,7 @@ function minify(data) {
   var options = this.options;
   var context = this.context;
 
-  var commentsProcessor = new CommentsProcessor('keepSpecialComments' in options ? options.keepSpecialComments : '*', options.keepBreaks);
+  var commentsProcessor = new CommentsProcessor(options.keepSpecialComments, options.keepBreaks);
   var expressionsProcessor = new ExpressionsProcessor();
   var freeTextProcessor = new FreeTextProcessor();
   var urlsProcessor = new UrlsProcessor();