Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: cssnano does not manage relative color syntax with calculation #1740

@MerlinChatou

Description

@MerlinChatou

Describe the bug

When the CSS contains color relative syntax with calculation like this:

oklch(from var(--accent-l) calc(l + 0.05) c h);

We get an error at build time:

  Erroneous area:
1: l + 0.05
^..^ [postcss-calc]
57:3    ⚠  Lexical error on line 1: Unrecognized text.

Expected behaviour

We expect cssnano to detect relative color syntax as an exception.

Steps to reproduce

Add a relative color with a calculation in the css

oklch(from var(--accent-l) calc(l + 0.05) c h);

Run css nano with default parameters

Version

7.1.2

Preset

default

Environment

System:
    OS: Linux 6.14 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat)
    CPU: (32) x64 Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz
    Memory: 52.71 GB / 62.52 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash

Package details

Additional context

I tried added /* postcss-calc: ignore */ before problematic lines, but comment seems to be removed before processing the line.

I tried @csstools/postcss-relative-color-syntax but doesn't work either.

It seems that newer versions of postcss-calc support relative color syntax

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