* Breaks 2.x compatibility for using CleanCSS as a function.
* Reworks minification to tokenize first then minify.
See [changes](https://github.com/jakubpawlowicz/clean-css/compare/b06f37d...dd8c14a).
+* Renames `noAdvanced` option into `advanced`.
* Speeds up advanced processing by shortening optimize loop.
* Fixed issue [#360](https://github.com/GoalSmashers/clean-css/issues/360) - adds 7 extra CSS colors.
npm install clean-css
```
+### How to upgrade clean-css from 2.x to 3.x?
+
+#### Command-line interface (CLI) - no breaking changes.
+
+#### Module interface
+
+* `noAdvanced` became `advanced` - make sure to reverse the value;
+
### How to upgrade clean-css from 1.x to 2.x?
#### Command-line interface (CLI)
CleanCSS constructor accepts a hash as a parameter, i.e.,
`new CleanCSS(options).minify(source)` with the following options available:
+* `advanced` - set to false to disable advanced optimizations - selector & property merging, reduction, etc.
* `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)
* `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
if (commands.skipRebase)
cleanOptions.noRebase = true;
if (commands.skipAdvanced)
- cleanOptions.noAdvanced = true;
+ cleanOptions.advanced = false;
if (commands.skipAggressiveMerging)
cleanOptions.noAggressiveMerging = true;
if (commands.compatibility)
options = options || {};
this.options = {
+ advanced: options.advanced === undefined ? true : false,
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,
var urlRebase = new UrlRebase(options, context);
var selectorsOptimizer = new SelectorsOptimizer({
keepBreaks: options.keepBreaks,
- noAdvanced: options.noAdvanced,
+ advanced: options.advanced,
compatibility: options.compatibility,
aggressiveMerging: !options.noAggressiveMerging,
roundingPrecision: options.roundingPrecision
var tokens = new Tokenizer(this.context).toTokens(data);
new SimpleOptimizer(this.options).optimize(tokens);
- if (!this.options.noAdvanced)
+ if (this.options.advanced)
new AdvancedOptimizer(this.options, this.context).optimize(tokens);
return rebuild(tokens, this.options.keepBreaks, false).trim();
var lineBreak = process.platform == 'win32' ? '\r\n' : '\n';
var cssContext = function(groups, options) {
var context = {};
+
var clean = function(expectedCss) {
return function(css) {
var minifiedCss = new CleanCSS(options).minify(css);
'@import url(//fonts.googleapis.com/css?family=Domine:700);body h1{font-family:Domine}'
],
'no empty body': '@import url(//fonts.googleapis.com/css?family=Domine:700);body{color:red}body h1{font-family:Domine}'
- }, { processImport: false, noAdvanced: true }),
+ }, { processImport: false, advanced: false }),
'duplicate selectors with disabled advanced processing': cssContext({
'of a duplicate selector': [
'a,a{color:red}',
'a{color:red}'
]
- }, { noAdvanced: true }),
+ }, { advanced: false }),
'line breaks with disabled advanced processing': cssContext({
'should be applied': [
'a{color:red}p{display:block}',
'a{color:red}' + lineBreak + 'p{display:block}'
]
- }, { noAdvanced: true, keepBreaks: true }),
+ }, { advanced: false, keepBreaks: true }),
'invalid data tokenization': cssContext({
'extra top-level closing brace': [
'a{color:red}}p{width:auto}',
'a{padding:10px;margin:0;color:red}.one{color:red}a,p{color:red;padding:0}',
'a{margin:0}.one{color:red}a,p{color:red;padding:0}'
]
- }, { noAdvanced: false, aggressiveMerging: true })
+ }, { advanced: true, aggressiveMerging: true })
)
.addBatch(
optimizerContext('advanced on & aggressive merging off', {
'a{padding:10px;margin:0;color:red}.one{color:red}a,p{color:red;padding:0}',
'a{padding:10px;margin:0}.one{color:red}a,p{color:red;padding:0}'
]
- }, { noAdvanced: false, aggressiveMerging: false })
+ }, { advanced: true, aggressiveMerging: false })
)
.addBatch(
optimizerContext('advanced off', {
'a{color:red;display:block}.one{font-size:12px}a{color:#fff;margin:2px}',
'a{color:red;display:block}.one{font-size:12px}a{color:#fff;margin:2px}'
]
- }, { noAdvanced: true })
+ }, { advanced: false })
)
.addBatch(
optimizerContext('@charset', {