npm / cssnano
cssnano
What changed in cssnano 4 to 9, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-26.
26 breaking2 security1 deprecations4 new APIs and options6 performance26 behavior and defaults3 tooling71 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initcssnano 974 changes
Breaking changes 13
Projects that require this package directly must declare it as a dependency or switch to the default preset configuration.
Overrides that pin an individual plugin no longer apply.
Resolutions that pin an individual plugin no longer apply.
The presets no longer run postcss-svgo; run it before cssnano or optimize SVG assets with the SVGO cli instead.
The svgo option is now ignored, so it no longer configures SVG optimization through the preset.
Accepts an optional leading rounding strategy when ordering animations and transitions or folding shorthands, provided the strategy is separated by a comma.
Longhand merging now stops at nested rules and at-rules without blocks, preventing generated shorthands from overriding nested declarations.
A non-function
removeoption now fails with a TypeError.Automatic lookup now checks only the current working directory, searching .cssnanorc.json and then cssnano.config.js; parent directories and other locations are no longer searched.
The package is now ESM-only, and deep imports such as cssnano/src, cssnano/src/index.js, and cssnano-preset-default/src are no longer available.
cssnano migrates to ESM, which may affect how developers load it.
cssnano 9.0 requires Node.js 22.22.3 or later in 22.x, 24.15.0 or later in 24.x, or 26.0 and later.
When loading a preset fails, cssnano no longer retries with the cssnano-preset- prefix; it attempts only the name provided.
Deprecations 1
An installed preset package takes precedence over the built-in preset and prints a one-time warning; pass the imported preset function to avoid it.
New APIs and options 2
Accepts Browserslist options for determining browser support when merging alignment properties.
A new postcss-calc plugin is introduced.
Performance 2
Reduces whitespace in css-grid-template.
Caches Browserslist lookups across runs.
Behavior and default changes 21
Full preset names fall back to the built-in preset when the corresponding package is not installed.
Always converts between cm and mm, and converts q to cm or mm; q is never the output unit.
Merges at-rules separated by unrelated rules.
Drops a min-* or max-* already implied in another range in the same media query.
Merges row-gap/column-gap, overscroll-behavior-x/-y, flex-direction/flex-wrap, column-rule-* and equal overflow-x/-y into shorthands when every target supports them.
Minifies Unicode in CSS.
cssnano merges more overridden declarations.
cssnano now merges non-adjacent rules.
Merges compatible box alignment longhands into this shorthand only when every targeted browser supports it.
Its updated calculation behavior attempts to preserve fractions when a replacement would lose too much precision.
Writes numbers in scientific notation when shorter, including when length unit conversion is disabled; integers retain their form.
Merge margin, padding, border, border-radius, columns, and border-spacing declarations inside at-rule containers, and fold identical horizontal and vertical border-spacing components.
Four complete corner longhands in the same importance lane can merge into a shorthand, with horizontal and vertical axes minified independently.
Removes insignificant whitespace around custom-property names while preserving authored value whitespace, required token boundaries, empty fallback whitespace, and comments.
Duplicate keyframes and counter-style definitions are merged more conservatively.
Renames identifiers only when definitions and references are in the same stylesheet, and avoids renaming names in specified functions, fallbacks, or reserved words.
Uses deterministic shortest non-crossing canonical shorthands from complete side and component groups, while respecting importance lanes, cascade barriers, and partial grids.
Minifies equal components in two-axis, four-side, alignment, aspect-ratio, and transition declarations while preserving grammar-sensitive and invalid values.
Margin, padding, and physical border shorthand property names and case-insensitive keywords are canonicalized to lowercase while unmerged longhands and unresolved values retain author casing.
Follows WHATWG fragment handling, leaves non-conforming data URLs untouched, recognizes CSS hex escapes in schemes, and optimizes eligible SVG URLs while preserving modifiers and comments.
Configuration loading is simplified, with some changes documented in the migration guide.
Tooling 1
cssnano ships its presets and plugins in one package, reducing the dependency tree from about thirty packages to one.
Fixes and other changes 34
The lite and advanced presets work without installing another package.
Only the url() token is normalized; URLs remain byte-identical, and whitespace inside quoted @namespace URLs is preserved.
Improves escape handling in selectors.
Fixes merging of long selectors.
Improves handling of box-shadow and animation values.
Fixes a crash caused by depending on an unpublished version of cssnano-utils.
Avoids an infinite loop in postcss-merge-rules.
Removes redundant sibling at-rules during CSS optimization.
Shortens
top center,bottom center,center topandcenter bottomto the corresponding single keyword.Leaves positions unchanged when rewriting could be unsafe because of split background values, functions that may return keywords, or invalid three-value positions containing math functions.
Leaves the rule unchanged because browsers only recognize it with double quotes.
Only treats a dimension with a length unit as the font size, leaving invalid shorthand values unchanged.
Leaves the shorthand unchanged when it contains
attr(),if(),inherit()or a custom function, whose results are only known at computation time.Removes a zero stop position only when its type is valid for the gradient; conic gradients drop
0degbut retain invalid0px.Leaves rules with invalid selectors unchanged, including digit-leading ID selectors and combinators after pseudo-elements.
Rules with invalid selectors are no longer merged, avoiding invalid selector lists that cause browsers to drop otherwise valid rules.
Does not turn comments inside selectors into descendant combinators, and leaves invalid selectors as written.
Preserves strings when removing a line continuation after an escape would change how the escape is parsed.
Preserves
todirections as written because the prefixed syntax measures angles differently.Redundant whitespace in at-rules is now collapsed.
Preserves unicode ranges during value conversion.
Restricts color minification to color-accepting properties and custom properties, adds hwb() and nested-function support, and preserves custom identifiers and relative color syntax.
Recognizes count and math-function shorthands in either order, outputs
auto 2for2 auto, and preserves zero lengths and invalid declarations.Comment detection respects CSS token boundaries, kept comments remain byte-for-byte intact, per-document state is isolated, and the remove callback runs once per occurrence.
Preserves zero percentage units where required, respects disabled 0ms conversions, and clamps percentage opacity values according to CSS Color 4 alpha semantics.
Preserves units in
@property, keyframes, font override descriptors, anchor(), flex-basis, and IE-targeted sizing properties, and preserves SVG stroke zero percentages.Math-function recognition is standardized across value transforms; spacing around division is preserved, nested calculation commas are trimmed, and CSS Values 4 math functions are handled consistently.
URL normalization decodes quoted values, uses POSIX path semantics, preserves escapes and control-character quotes, and safely handles namespace URLs and multiline continuations.
Preserves percentage units in registered custom-property initial values with composite syntax, ranges, groups, and multipliers.
SVG decoding now follows the WHATWG specification.
Conflict detection and color conversion were updated for CSS spec conformance.
Adds the main field to package manifests.
Adds the types field to package manifests.
The calc() minifier was entirely rewritten and should support most cases that previously triggered console warnings.
cssnano 827 changes
Breaking changes 3
Selector minification tightens :is() fold acceptance to a strict allowlist.
The declaration sorter moved to the advanced preset, so developers using it need that preset.
Support for Node.js 20 was dropped.
Security 1
Packages define an exports field in package.json, preventing newly added files from automatically becoming importable while preserving imports available in the previous release.
Performance 4
Includes a small performance fix.
Buckets rules by selector.
Skips processors with no relevant declarations.
Adds fast paths for common cases.
Behavior and default changes 1
Updates the initial properties handled by the plugin.
Tooling 2
Types have been regenerated with TypeScript 7.
Includes postcss-discard-overridden types in the package.
Fixes and other changes 16
Charset normalization is now idempotent, so applying it repeatedly does not change the result further.
Fixes gradient minification to use the spec algorithm.
Option types were tightened, helping developers use valid options.
Cascade layers are optimized better.
Improves longhand merging correctness, including cases found by a fuzzer.
Fixes invalid rule merging.
Uses webref data to perform merges.
Avoids breaking grid-template-areas.
Improves selector minification.
Fixes issues with border merging.
Fixes an encoding issue in postcss-svgo.
Preserves trailing slashes in URLs.
Preserves whitespace in custom properties.
Handles gradients with more than two stops.
Preserves apostrophes in SVG data URIs.
Selector minification no longer folds :is() when the divergent middle contains a combinator under a non-empty prefix.
cssnano 79 changes
Breaking changes 1
Drops support for Node.js 14, 16, 19, and 21, and adds support for Node.js 22.
New APIs and options 2
Adds the transformCustomProperties option.
Adds the transformCustomProperties option.
Behavior and default changes 1
cssnano can fold selector lists into :is().
Fixes and other changes 5
Rejects :is() folding for unknown pseudo-classes with arguments.
Rejects :is() folding for :nth-child(... of S) to preserve the cascade.
postcss-reduce-idents now supports the counter-set property.
Updates the color conversion library to fix rounding errors in color conversions.
Recognition of CSS comments was enhanced.
cssnano 63 changes
Breaking changes 3
The minimum supported Node version is now 14 for all packages.
Configuration options for the normalize-url transform were removed; turn the transform off completely if you do not want its defaults.
YAML configuration is no longer supported; move cssnano configuration into the PostCSS config or use a CommonJS or JSON configuration file.
cssnano 514 changes
Breaking changes 2
The JavaScript API changes from cssnano.process() to cssnano().process(), and cssnano options are passed to cssnano() instead of process().
cssnano 5 requires Node >= 10.13.
Security 1
Removes a vulnerable dependency and always warns with bad SVG input.
Behavior and default changes 1
cssnano uses the PostCSS 8 API and does not emit warnings when running under PostCSS 8.
Fixes and other changes 10
Fixes minification of aspect-ratio.
The updated parser fixes many bugs.
Fixes improperly discarded @font-face declarations.
Fixes sorting of longhand and shorthand properties.
Fixes minification of percentage values.
Partially fixes cases where cssnano did not combine rules when used with postcss-nested.
Fixes merging of @supports rules.
cssnano updates to SVGO 2, fixing many SVG minification bugs.
Fixes translate3d() minification.
Fixes minification of values starting with e.
cssnano 412 changes
Breaking changes 4
Support for Node 4 was dropped; Node 6.9 is now the minimum required version.
No longer removes
allfor IE.Stops changing U to lowercase for IE 11 and earlier and Edge 15 and earlier.
No longer handles an empty url function.
Behavior and default changes 2
Adds whitespace after a minified value and before a function.
The optimizer now optimises the border-spacing property.
Fixes and other changes 6
Correctly handles border-style declarations with custom properties.
Correctly handles the
:-ms-input-placeholderand::-ms-input-placeholderselectors.Correctly handles the all property.
More accurately escapes font names.
Correctly handles data and *-extension:// URLs.
Correctly handles the border property when its border width value is invalid.