Releases: cssnano/cssnano
Release list
v9.2.1
What's Changed
- fix(postcss-discard-duplicates): remove redundant sibling at-rules in #2010
Full Changelog: https://github.com/cssnano/cssnano/compare/cssnano@9.2.0...cssnano@9.2.1
v9.2.0
Features
- Merge box alignment properties into the
place-content,place-itemsandplace-selfshorthands, such asalign-items:center;justify-items:startintoplace-items:center start. This only happens when every browser in your Browserslist targets supports the shorthands, because a browser that does not would ignore both alignments. Thedefaultsquery includes browsers with unknown support, such as Opera Mini and UC Browser, so it keeps the longhands. Values that usesafe,unsafeorlast baselinemerge only when both values use the same keywords.postcss-merge-longhandnow accepts the Browserslist optionsoverrideBrowserslist,stats,pathandenv.
Fixes
-
Write numbers in scientific notation when it is shorter, such as
1e-6pxfor0.000001pxand1e6pxfor1000000px. This also applies whenlengthunit conversion is disabled. Numbers written without a decimal point, such asz-index:1000000, keep their form, because an<integer>cannot use scientific notation. -
Stop merging longhands across a nested rule or at-rule. The shorthand ended up after the nested rule and overrode it, so in
a{margin-top:1px;&{margin-top:2px}…}the nestedmargin-topwas lost. This applies tomargin,padding,border,border-radiusandcolumns. Declarations on each side of a nested rule are now merged separately. An at-rule without a block, such as@apply x;, also separates them, since it may add declarations. An empty rule such as&{}does not. Aborder-imageoralldeclaration before a nested rule no longer prevents merging theborderlonghands after it. -
Stop merging rules that have an invalid selector, such as
b: hover,[a b],:lang(en fr)ora||b. An invalid selector makes the whole selector list invalid, so the browser also dropped the valid rule it was merged with. -
Only treat a dimension as the font size in the
fontshorthand when it has a length unit. An invalid value such asfont:bold 1s "Arial Black"is now left unchanged. -
Leave the
fontshorthand unchanged when it containsattr(),if(),inherit()or a custom function such as--name(), as already done forvar()andenv(). Their result is only known when the browser computes the value. -
Remove a zero color stop position only when it has the right type for the gradient.
conic-gradient()now drops0degand keeps an invalid0px, while linear and radial gradients still drop0px.-webkit-linear-gradient()keepsto bottomand othertodirections as written, since the prefixed syntax measures angles differently. -
Stop turning a comment inside a selector into a descendant combinator. A comment is not whitespace, so
.a/**/.bselects elements with both classes, including inside:is(), and is no longer rewritten as.a .b. Invalid selectors such asdiv/**/spanare left as written instead of becoming valid. -
Leave rules with an invalid selector unchanged, including an ID selector that starts with a digit, such as
#1a, and a combinator after a pseudo-element, such asa::before b. -
Shorten
top centerandbottom centertotopandbottom, instead of0and100%, which the browser reads as horizontal positions.center topandcenter bottomare now shortened the same way.Leave a position unchanged when it cannot be safely rewritten:
- in a
backgroundlayer where another value splits the position, as inleft no-repeat center, which is invalid; - when it contains a function such as
attr(),if()or a custom--function(), which may return a keyword, asvar()already did; - when an invalid three-value position contains a math function, such as
left abs(1px) top, ascalc()already did.
- in a
-
Keep strings unchanged when removing a line continuation (a backslash before a newline) right after an escape. In
"\31followed by a line continuation and2", joining the lines would turn\31into\312, so the result is now"\31 2".Leave
@charsetunchanged. Browsers only recognize it with double quotes, so rewriting single quotes would make an ignored@charsettake effect. -
Update
postcss-calcto 11.2.2. postcss-calc() now attempts to preserve fractions if the replacement would lose too much precision
v9.1.2
What's Changed
- fix: collapse redundant whitespace in at-rules in #1999
Full Changelog: https://github.com/cssnano/cssnano/compare/cssnano@9.1.1...cssnano@9.1.2
v9.1.1
What's Changed
Bug Fixes
- fix(postcss-convert-values): preserve unicode range in #1995
Full Changelog: https://github.com/cssnano/cssnano/compare/cssnano@9.1.0...cssnano@9.1.1
v9.1.0
What's Changed
New Features
- Merge corner
border-*-radiuslonghands intoborder-radiusshorthands. Four complete corner declarations in the same importance lane now collapse into one shorthand, with horizontal and vertical axes minified independently and separated by a slash when distinct.
Bug fixes and Improvements
-
Merge margin, padding, border, border-radius, columns, and border-spacing declarations inside at-rule containers such as
@page,@position-try, and nested at-rules. Fold identical horizontal and verticalborder-spacingcomponents to a single value. Recognizecolumnsshorthands combining a count and a math function in either order, and preserve invalid declarations as written: border shorthands with multiple styles andcolumnsvalues combining CSS-wide keywords with widths or counts no longer discard preceding valid longhands. -
Preserve percentage units in registered custom-property initial values with composite syntax, ranges, groups, and multipliers, and avoid clamping numeric operands nested inside alpha-value functions.
-
Restrict color minification to CSS properties that accept
<color>and custom properties, preserving custom identifiers in properties likeanimation-name,grid-area, andcounter-reset. Add support forhwb()color values and minification insidecolor-mix(),light-dark(), andvar()fallbacks, while preserving relative color syntax, math functions, and token boundary separators. -
Preserve zero percentage units in rgb(), rgba(), and modern CSS Color 4 functions to avoid invalid syntax, respect disabled time conversions for 0ms, clamps percentage opacity values adhering to CSS Color 4 alpha semantics, and improve compatibility with uppercase at-rules and vendor-prefixed keyframes.
-
Preserves zero length in
columnsshorthands and zero units inside@propertywith<angle-percentage>syntax, retaining keyframe percentage units under nested rules. Symmetrically rounds negative numbers when precision is configured, converts between metric units (mm,cm,q), preserves zero percentages on SVG stroke properties to retain transition interpolation, and caches Browserslist lookups across runs. Also preserves units inside CSS Fonts 5 override descriptors,anchor()functions,flex-basis, and IE-targeted sizing properties. -
Remove comments more reliably and preserve the ones you keep exactly. Comments are now removed from
!importantdeclaration values and comment detection respect CSS token boundaries: text inside unquotedurl()values and behind escape sequences in strings and identifiers is no longer mistaken for a comment. Kept comments are emitted byte-for-byte, including an unclosed comment at the end of a value, and whitespace inside kept comments is left untouched. Removal state is scoped to each document, so a shared processor no longer carriesremoveAllButFirstfirst-comment state between runs, and theremovecallback runs once per comment occurrence. A non-functionremoveoption now fails with aTypeError. -
Improve conformance for modern CSS math functions, grid-line values, and case-sensitive attribute selector modifiers while preserving ambiguous or invalid declarations. The affected transforms now use bounded, linear scans for these forms.
-
Value transforms now read the CSS Values 4 math function names from one
mathFunctionstable incssnano-utils, so unit retention, box and shorthand merging, parameter and whitespace handling, and time classification agree on which functions count as math functions. Serialized output is unchanged. -
Standardize output normalization for margin, padding, and physical border properties. Property names and case-insensitive keywords in generated shorthands and normalized standalone shorthand declarations are canonicalized to lowercase, while preserving author casing for unmerged longhands, custom properties, hack prefixes, and unresolved values.
-
perf: median 15% speed increase on test fixtures
-
postcss-normalize-urlnow decodes quotedurl(...)values, preserving literal backslashes and escape sequences whether quotes are stripped or kept.
Relative URLs now normalize using POSIX path semantics across all platforms, and converted@namespaceURLs escape double quotes. -
Join every escaped line continuation in a multiline
url()value into one line, including\r\ncontinuations that previously left an invalid string behind. Rewriting a@namespaceURL no longer overwrites the tokens that follow it, so trailing text is preserved and multiple URLs in one namespace declaration are each normalized. -
Remove insignificant whitespace around custom-property names and, in standard declarations, around
env()custom-ident arguments and around comma delimiters invar(),env(), andconstant(). Between a custom-property name and its value, only the parser-consumed leading whitespace run is dropped; authored whitespace elsewhere in the value, such as after a preserved comment, is preserved per CSS Variables 2. Required whitespace between distinct tokens and the single whitespace token in an empty fallback remain preserved, and a preserved comment kept between a declaration name and value now survives minification, for custom properties and standard declarations alike. Comment removal in selectors and values no longer fuses the tokens the comment in-between: an attribute case-insensitivity flag or any other name-like token keeps its boundary, and math-operator spacing is restored for every function whose value productions accept<calc-sum>arguments (includingcalc-size(),calc-mix(), andrandom()). Values without comments are now left byte-for-byte untouched rather than re-spaced. -
Preserve whitespace around division operators across all modern CSS math functions such as
min(),max(), andclamp(), and trim extraneous whitespace from commas in nested calculations. -
Order
columns: 2 autoascolumns: auto 2. Leave animation declarations with negative iteration counts unchanged. Reorders border and box-shadow math functions that resolve to a length, such ascalc(1px + 1em), and leaves other math unchanged. Passes through unknown box-shadow color functions instead of reordering them. -
Merge duplicate
@keyframesand@counter-styledefinitions more conservatively. -
Use ASCII case-insensitive matching for CSS names and grammar keywords so Unicode lookalikes are preserved, and restrict CSS whitespace normalization to the CSS whitespace set.
-
Rename identifiers only when their definition and a reference are in the same stylesheet; leave alone names inside
var(),env(),attr(), or a custom property fallback; skip reserved words in the encoder; renamereversed()counters and implicit<area>-start/-endlines with their area. -
Preserve Windows drive roots, directory dot references, and leading
./prefixes when the first relative segment contains a colon. Decode unreserved percent-encoded octets while preserving percent-encoded dots, normalize@importat-rules including nested condition URLs, retain quotes for URLs containing non-printable control characters, avoid unnecessary declaration tokenization, and synchronize raw parameters. -
Minify equal shorthand components for two-axis, four-side, alignment, aspect-ratio, and transition declarations while preserving grammar-sensitive and invalid values.
-
fix(postcss-minify-params): support CSS values level 4 and Media Queries level 5
-
Preserves invalid selector syntax and namespace-sensitive universal selectors while safely normalizing pseudo-element, View Transition, and keyframe forms. Recognizes the full token grammar for An+B formulas, including escaped forms and exact large integers.
-
fix(postcss-ordered-values): improve performance and correctness
-
Aligns SVG data URI processing with WHATWG URL standards by treating the first
#as the fragment delimiter. Non-conforming data URLs (such as those with malformed percent-encoding or where an unencoded#in markup truncates the SVG payload) are left untouched rather than parsed with an internal XML recovery scanner. CSS hex escapes in the URI scheme (for exampled\61ta:image/svg+xml) reach the optimizer. SVG data URIs inside CSS Values 4src(...)functions orurl(...)declarations with url-modifiers are optimized while preserving modifiers and comments. Minified declarations also keep their raw value metadata in sync. -
Unify physical-border optimization under a single reducer that chooses deterministic shortest non-crossing canonical shorthands from complete side and component groups, partitioned by importance lane. Partial grids no longer require a full border reset. Dynamic declarations, style hacks, CSS-wide keywords, support fallbacks, unresolved substitutions, and other cascade barriers remain in their original positions, while valid fallback and border-image behavior is preserved.
-
Parse font weights and column units from tokenizer metadata. This safely minifies escaped
boldweights, recognizes escaped length units, and prevents partial rewrites of invalid font shorthands while preserving original source spelling. -
Update browserslist
-
Preserve matching-importance all reset boundaries when merging margin, padding, physical border-radius, and columns declarations, so minification does not restore values cleared by the reset.
Full Changelog: https://github.com/cssnano/cssnano/compare/cssnano@9.0.5...cssnano@9.1.0
v9.0.5
What's Changed
Bug Fixes
- fix(postcss-svgo): decode SVG following WHATWG specification in #1975
Other changes
- Update dependencies
Full Changelog: https://github.com/cssnano/cssnano/compare/cssnano@9.0.4...cssnano@9.0.5
v9.0.4
What's Changed
- fix: update postcss-calc in #1970
Full Changelog: https://github.com/cssnano/cssnano/compare/cssnano@9.0.3...cssnano@9.0.4
v9.0.3
What's Changed
-
fix: update color parsing library in #1964
-
fix: update PostCSS and selector parser
-
fix: update conflict detection and color conversion CSS spec conformance
-
fix: update PostCSS peer dependency
Full Changelog: https://github.com/cssnano/cssnano/compare/cssnano@9.0.2...cssnano@9.0.3
v9.0.2
What's Changed
- fix: add main and types to package manifests in #1958
- fix: update postcss-calc
Full Changelog: https://github.com/cssnano/cssnano/compare/cssnano@9.0.1...cssnano@9.0.2
v9.0.1
What's Changed
- refactor: some small performance gains in #1955
Full Changelog: https://github.com/cssnano/cssnano/compare/cssnano@9.0.0...cssnano@9.0.1