* In API mode, set `mediaMerging` option to false.
* In CLI mode, add `--skip-media-merging` switch.
--skip-advanced Disable advanced optimizations - selector & property merging,
reduction, etc.
--skip-aggressive-merging Disable properties merging based on their order
+--skip-media-merging Disable `@media` merging
--skip-shorthand-compacting Disable shorthand compacting
--rounding-precision [N] Rounds to `N` decimal places. Defaults to 2. -1 disables rounding.
-c, --compatibility [ie7|ie8] Force compatibility mode (see Readme for advanced 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
+* `mediaMerging` - whether to merge `@media` blocks (default is true)
* `processImport` - whether to process `@import` rules
* `rebase` - set to false to skip URL rebasing
* `relativeTo` - path to __resolve__ relative `@import` rules and URLs
.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('--skip-media-merging', 'Disable @media merging')
.option('--skip-shorthand-compacting', 'Disable shorthand compacting')
.option('--rounding-precision [n]', 'Rounds to `N` decimal places. Defaults to 2. -1 disables rounding.', parseInt)
.option('-c, --compatibility [ie7|ie8]', 'Force compatibility mode (see Readme for advanced examples)')
inliner: commands.timeout ? { timeout: parseFloat(commands.timeout) * 1000 } : undefined,
keepBreaks: !!commands.keepLineBreaks,
keepSpecialComments: commands.s0 ? 0 : (commands.s1 ? 1 : '*'),
+ mediaMerging: commands.skipMediaMerging ? false : true,
processImport: commands.skipImport ? false : true,
rebase: commands.skipRebase ? false : true,
root: commands.root,
inliner: options.inliner || {},
keepBreaks: options.keepBreaks || false,
keepSpecialComments: 'keepSpecialComments' in options ? options.keepSpecialComments : '*',
+ mediaMerging: undefined === options.mediaMerging ? true : !!options.mediaMerging,
processImport: undefined === options.processImport ? true : !!options.processImport,
rebase: undefined === options.rebase ? true : !!options.rebase,
relativeTo: options.relativeTo,
self.mergeNonAdjacentBySelector(tokens);
self.mergeNonAdjacentByBody(tokens);
- var reduced = self.mergeMediaQueries(tokens);
- for (var i = reduced.length - 1; i >= 0; i--) {
- _optimize(reduced[i].body);
+ if (self.options.mediaMerging) {
+ var reduced = self.mergeMediaQueries(tokens);
+ for (var i = reduced.length - 1; i >= 0; i--) {
+ _optimize(reduced[i].body);
+ }
}
}
}
})
},
+ '@media merging': pipedContext('@media screen{a{color:red}}@media screen{a{display:block}}', '--skip-media-merging', {
+ 'gets right result': function (error, stdout) {
+ assert.equal(stdout, '@media screen{a{color:red}}@media screen{a{display:block}}');
+ }
+ }),
'shorthand compacting': {
'of (yet) unmergeable properties': pipedContext('a{background:url(image.png);background-color:red}', '--skip-shorthand-compacting', {
'gets right result': function(error, stdout) {
assert.equal(minified.styles, '/*! a comment */@media screen{a{color:red;display:block}}');
}
}
+ })
+ .addBatch({
+ 'disabled': {
+ topic: new CleanCSS({ mediaMerging: false }).minify('@media screen{a{color:red}}@media screen{a{display:block}}'),
+ 'keeps @media intact': function(minified) {
+ assert.equal(minified.styles, '@media screen{a{color:red}}@media screen{a{display:block}}');
+ }
+ }
}).export(module);