Skip to content

[Bug]: Invalid initial-value for custom CSS percentage property #1694

@aramikuto

Description

@aramikuto

Describe the bug

The initial-value of 0% in a custom CSS percentage property is incorrectly minified to 0, dropping the percent sign. The value 0 without the percent sign is invalid for properties defined with <percentage> syntax.

This issue occurs with both the default and advanced profiles. The lite profile correctly preserves the percent sign.

Input:

@property --ratio {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

Output:

@property --ratio{syntax:"<percentage>";inherits:false;initial-value:0}

Expected behaviour

The percent sign should be preserved in the minified output:

@property --ratio{syntax:"<percentage>";inherits:false;initial-value:0%}

Steps to reproduce

  1. Open the sniped in the online playground.
  2. Minify using the default profile.

Version

7.0.6

Preset

default

Environment

System:
  OS: macOS 15.4.1
  CPU: (8) arm64 Apple M2
  Memory: 152.61 MB / 24.00 GB
  Shell: 5.9 - /bin/zsh

Package details

├─┬ cssnano@7.0.6
│ ├─┬ cssnano-preset-default@7.0.6
│ │ ├─┬ css-declaration-sorter@7.2.0
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ cssnano-utils@5.0.0
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-calc@10.1.1
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-colormin@7.0.2
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-convert-values@7.0.4
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-discard-comments@7.0.3
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-discard-duplicates@7.0.1
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-discard-empty@7.0.0
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-discard-overridden@7.0.0
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-merge-longhand@7.0.4
│ │ │ ├── postcss@8.5.3 deduped
│ │ │ └─┬ stylehacks@7.0.4
│ │ │   └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-merge-rules@7.0.4
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-minify-font-values@7.0.0
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-minify-gradients@7.0.0
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-minify-params@7.0.2
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-minify-selectors@7.0.4
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-normalize-charset@7.0.0
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-normalize-display-values@7.0.0
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-normalize-positions@7.0.0
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-normalize-repeat-style@7.0.0
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-normalize-string@7.0.0
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-normalize-timing-functions@7.0.0
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-normalize-unicode@7.0.2
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-normalize-url@7.0.0
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-normalize-whitespace@7.0.0
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-ordered-values@7.0.1
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-reduce-initial@7.0.2
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-reduce-transforms@7.0.0
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-svgo@7.0.1
│ │ │ └── postcss@8.5.3 deduped
│ │ ├─┬ postcss-unique-selectors@7.0.3
│ │ │ └── postcss@8.5.3 deduped
│ │ └── postcss@8.5.3 deduped
│ └── postcss@8.5.3 deduped
├─┬ postcss-cli@11.0.1
│ ├─┬ postcss-load-config@5.1.0
│ │ └── postcss@8.5.3 deduped
│ ├─┬ postcss-reporter@7.1.0
│ │ └── postcss@8.5.3 deduped
│ └── postcss@8.5.3 deduped
└── postcss@8.5.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions