Skip to content

PostCSS/esbuild/Vite token-fallback plugins incorrectly rewrite var()-like text inside strings #82169

Description

@simison

The design-token fallback plugins are inconsistent in how they handle var(--wpds-*) references that appear inside string literals (e.g. content: "var(--wpds-border-radius-sm)";) rather than as actual CSS var() functions.

Discovered while reviewing #80401 (comment thread)

Lightning CSS's behavior is already correct:

Plugin Behavior
PostCSS Regexp-based — matches and rewrites the text anywhere in the declaration, including inside quoted strings.
esbuild / Vite Skip CSS files but rewrite the same text anywhere in JS/TS source.
Lightning CSS AST-based — only adds fallbacks to parsed var() functions; leaves plain strings untouched.

Ask: Align the PostCSS (and esbuild/Vite) plugins in packages/theme/postcss-plugins (and equivalents) to only inject fallbacks for actual var() function references, not incidental text matches inside strings/comments, matching Lightning CSS's AST-aware behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueAn issue that's suitable for someone looking to contribute for the first time[Package] Theme/packages/theme[Status] In ProgressTracking issues with work in progress

    Type

    Projects

    Status
    Review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions