Using `--skip-aggressive-merging` / `noAggressiveMerging` switch skips property merging based on order.
Will be fixed in #290.
* Fixed issue [#184](https://github.com/GoalSmashers/clean-css/issues/184) - uses `!important` for optimization opportunities.
* Fixed issue [#190](https://github.com/GoalSmashers/clean-css/issues/190) - uses shorthand to override another shorthand.
* Fixed issue [#197](https://github.com/GoalSmashers/clean-css/issues/197) - adds borders merging by understandability.
+* Fixed issue [#210](https://github.com/GoalSmashers/clean-css/issues/210) - adds temporary workaround for aggressive merging.
* Fixed issue [#246](https://github.com/GoalSmashers/clean-css/issues/246) - removes IE hacks when not in compatibility mode.
* Fixed issue [#247](https://github.com/GoalSmashers/clean-css/issues/247) - removes deprecated `selectorsMergeMode` switch.
* Refixed issue [#250](https://github.com/GoalSmashers/clean-css/issues/250) - based on new quotation marks removal.
--skip-rebase Disable URLs rebasing
--skip-advanced Disable advanced optimizations - selector & property merging,
reduction, etc.
+--skip-aggressive-merging Disable properties merging based on their order
--rounding-precision [value] Rounding precision, defaults to 2
-c, --compatibility [ie7|ie8] Force compatibility mode
-d, --debug Shows debug information (minification time & compression efficiency)
.option('-s, --skip-import', 'Disable @import processing')
.option('--skip-rebase', 'Disable URLs rebasing')
.option('--skip-advanced', 'Disable advanced optimizations - selector & property merging, reduction, etc.')
+ .option('--skip-aggressive-merging', 'Disable properties merging based on their order')
.option('--rounding-precision [value]', 'Rounding precision, defaults to 2', parseInt)
.option('-c, --compatibility [ie7|ie8]', 'Force compatibility mode')
.option('-t, --timeout [seconds]', 'Per connection timeout when fetching remote @imports (defaults to 5 seconds)')
cleanOptions.noRebase = true;
if (commands.skipAdvanced)
cleanOptions.noAdvanced = true;
+if (commands.skipAggressiveMerging)
+ cleanOptions.noAggressiveMerging = true;
if (commands.compatibility)
cleanOptions.compatibility = commands.compatibility;
if (commands.roundingPrecision !== undefined)
data = new SelectorsOptimizer(data, context, {
keepBreaks: options.keepBreaks,
lineBreak: lineBreak,
- compatibility: options.compatibility
+ compatibility: options.compatibility,
+ aggressiveMerging: !options.noAggressiveMerging
}).process();
});
}
var overrideCompactor = require('./override-compactor');
var shorthandCompactor = require('./shorthand-compactor');
-module.exports = function Optimizer(compatibility) {
+module.exports = function Optimizer(compatibility, aggressiveMerging) {
var overridable = {
'animation-delay': ['animation'],
'animation-direction': ['animation'],
// e.g. a{display:inline-block;display:-moz-inline-box}
// however if `mergeablePosition` yields true then the rule does not apply
// (e.g merging two adjacent selectors: `a{display:block}a{display:block}`)
- if (_property != lastProperty || mergeablePosition(i)) {
+ if (aggressiveMerging && _property != lastProperty || mergeablePosition(i)) {
while (true) {
toOverridePosition = properties.indexOf(_property, toOverridePosition);
if (toOverridePosition == -1)
var minificationsMade = [];
- var propertyOptimizer = new PropertyOptimizer(options.compatibility);
+ var propertyOptimizer = new PropertyOptimizer(options.compatibility, options.aggressiveMerging);
var cleanUpSelector = function(selectors) {
if (selectors.indexOf(',') == -1)
assert.equal(stdout, 'div{width:1px}');
}
})
+ },
+ 'neighbour merging': {
+ 'of (yet) unmergeable properties': pipedContext('a{display:inline-block;color:red;display:-moz-block}', '--skip-aggressive-merging', {
+ 'gets right result': function(error, stdout) {
+ assert.equal(stdout, 'a{display:inline-block;color:red;display:-moz-block}');
+ }
+ }),
+ 'of mergeable properties': pipedContext('a{background:red;display:block;background:white}', '--skip-aggressive-merging', {
+ 'gets right result': function(error, stdout) {
+ assert.equal(stdout, 'a{display:block;background:#fff}');
+ }
+ })
}
});
'a{display:none;border:1px solid #fff!important}'
]
}),
+ 'duplicate properties with aggressive merging disabled': cssContext({
+ 'of (yet) unmergeable properties': 'a{display:inline-block;color:red;display:-moz-block}',
+ 'of mergeable properties': [
+ 'a{background:red;display:block;background:white}',
+ 'a{display:block;background:#fff}'
+ ]
+ }, { noAggressiveMerging: true }),
'same selectors': cssContext({
'of two non-adjacent selectors': '.one{color:red}.two{color:#00f}.one{font-weight:700}',
'of two adjacent single selectors': [