cssnano 10

Ludovico Fischer ·

Although cssnano 10.0 is a major release, most users should be able to adopt it with minimal changes to their configuration. If you already call cssnano() without passing any options and target recent browsers, cssnano 10.0 works out-of-the-box.

Breaking Change: Reviewed Browser Compatibility

The highlight of this release is the browser compatibility setting. Before, browser targets were applied inconsistently within the code base and the default target included very old browsers. Now, the cssnano output is meant to be compatible with browsers that are Baseline widely available as of 30 November 2026.

Browser support affects minification: for example, it changes which declarations can be merged, as depending on which values and properties are supported, one declaration might or might not override another. To strike a balance between minification and build reproducibility, the default browserslist query without any configuration is baseline widely available on 2026-11-30 with downstream (see (Browserslist)[https://browsersl.ist/] for more information on the meaning of this query). Since the query is fixed at a specific date, the same input CSS with the same cssnano and dependency versions should always produce the same output. At the same time, we don’t limit minification options too much by trying to target browsers that are unlikely to be used. Just as before, the user Browserslist configuration, or the BROWSERSLIST environment variable, overrides the target browsers. To keep the previous targets, add a browserslist configuration with defaults, or pass browserslist: { query: 'defaults' } to cssnano.

cssnano({ browserslist: { query: 'defaults' } });

This release has removed code that explicitly supported browsers older than Internet Explorer 11: the workarounds for Internet Explorer 5.5 to 10, Firefox 2 and Opera 9. It is unlikely that cssnano would really have been able to output CSS compatible with these browsers anyway, and it has become difficult to test them. Internet Explorer 11 keeps its workarounds for zero units, media all and unicode-range.

Users are encouraged to set their own Browserslist query to the browsers they are targeting. Pass it to cssnano as browserslist: { query }, or use a browserslist configuration in a separate file. cssnano no longer reads env and stats from the options of the PostCSS process() call: pass them as browserslist: { env, stats }.

Internally, we streamlined the way settings are read and propagated across the code, so that the same compatibility constraints apply to every transformation pass. Browser targets passed to a single plugin, such as options: { colormin: { overrideBrowserslist: 'ie 11' } }, now throw an error, because ignoring them would silently widen the targets.

Configuration Options Reorganization

We took advantage of the major release to review the API and remove redundant ways to pass the same options. cssnano now takes four options, preset, disable, options and browserslist, either inline or in a configuration file. Options from different sources are not merged; instead, inline options override the configuration file completely. Removed and unknown options throw an error, and the message says where the setting moved.

Preset strings such as 'default' now throw an error

In previous releases, the configuration option format was not well-documented and it was not always clear what options were supposed to be valid and what the expected result would have been.

cssnano runs the default preset when no preset is given.

// cssnano 9
cssnano({ preset: 'default' });

// cssnano 10
cssnano();

Import the other presets from cssnano/presets/default, cssnano/presets/lite or cssnano/presets/advanced. Plugin settings in the preset array move to the disable and options keys:

cssnano 9 cssnano 10
preset: 'default' omit preset
preset: 'lite' preset: lite, imported from cssnano/presets/lite
preset: ['default', { colormin: false }] disable: ['colormin']
preset: ['default', { discardComments: { removeAll: true } }] options: { discardComments: { removeAll: true } }
overrideBrowserslist: 'ie 11' browserslist: { query: 'ie 11' }
path browserslist: { path }
svgo: false omit it
plugins: [...] add them to the PostCSS configuration

External configuration files must be in JavaScript modules

cssnano accepts inline configuration as before. To avoid confusion as to the source of cssnano settings and reduce the number of ways in which configuration is parsed, cssnano no longer reads .cssnanorc.json, and throws if it finds one in the working directory. Move the configuration to a cssnano.config.js module with a default export instead:

import lite from 'cssnano/presets/lite';

export default { preset: lite };

Merge options

Longhand merging, duplicate removal and rule merging are now a single transform, merge, because they are tightly intertwined: merging a rule might unlock declaration merges and vice versa.

  • disable: ['merge'] turns off all three.
  • options: { merge: { rules: false } } turns off rule merging only.

Longhand merging and duplicate removal can no longer be disabled separately, so disable: ['mergeLonghand'] and disable: ['discardDuplicates'] become disable: ['merge'], and disable: ['mergeRules'] becomes options: { merge: { rules: false } }.

Passing PostCSS plugins to the cssnano constructor has been removed

In the spirit of removing redundant and confusing options, the plugins option has been removed. Pass the PostCSS plugins to PostCSS directly instead. It is likely that few users were making use of this feature, as running cssnano requires instantiating PostCSS anyway.

The removeAllButFirst option has been removed

discardComments no longer has a removeAllButFirst option. Every comment marked as important (/*!) is now kept unless removeAll or remove asks to remove it. Passing removeAllButFirst to cssnano now throws an error. Important comments often contain licensing information. The goal of the removeAllButFirst option was likely to preserve only the comment containing the license, but many CSS files contain licenses also in subsequent important comments.

Other changes that might affect you

  • A built-in preset now returns a single cssnano-host PostCSS plugin instead of one plugin per transform, and merging reports as cssnano-merge. Code that filters result.messages or the plugin list by the old plugin names, such as postcss-merge-longhand or postcss-discard-empty, needs to use the new names.
  • Stylehacks is no longer a PostCSS plugin and is not part of the public package.
  • rgba(0,0,0,0) now becomes transparent.
  • initial is no longer rewritten for browsers without the initial keyword, such as Internet Explorer 11.
  • An existing @charset is dropped when its only non-ASCII text was in a rule that cssnano removes as empty.

New optimizations and fixes

cssnano now merges more longhands into their shorthands: outline, the logical borders (border-block-* and border-inline-*), grid-row, grid-column, grid-area, list-style, text-emphasis and text-decoration, where every target browser parses the shorthand.

This release also contains a long list of correctness fixes, where cssnano used to change the meaning of the CSS, and fixes for transforms that took more than linear time on large stylesheets. See the changelog for the full list.

Internal refactor

The code used to make a lot of passes over the tree, one for every transform. With the help of LLMs, the code has been refactored to first build an intermediate representation of the stylesheet, then process it in three phases: a walk down the tree that runs the value transforms, the merge, and a walk up the tree, before writing the result back to the PostCSS tree.

Unfortunately, the speed gains were not as large as expected, because building the intermediate representation consumes much of the time that was saved by reducing the number of passes, so the gains are around 10–20% as measured on the CSS samples in the cssnano repository. Nevertheless, this constitutes a stepping stone for an eventual standalone version and a port to a native language.