Skip to content

PostCSS: @layer order declaration is not stripped from CSS output when polyfill: true #3540

@CupNoodleFork

Description

@CupNoodleFork

Description

When I set polyfill: true in panda.config.ts and process my entry CSS file through @pandacss/dev/postcss, I expected the final CSS output to contain no @layer syntax at all — since the whole point of the polyfill is to make the output safe for browsers that don't support cascade layers.

index.css:

@layer reset, base, tokens, recipes, utilities;

But what happened instead is that the original @layer reset, base, tokens, recipes, utilities; order declaration from my source CSS is preserved in the final output.

output:

@layer reset, base, tokens, recipes, utilities;

:root {
  --made-with-panda: "🐼";
}

*, :before, :after, ::backdrop {
  --blur: /*-*/ /*-*/;
  --brightness: /*-*/ /*-*/;
...

Link to Reproduction

Steps to reproduce

  1. follow the https://panda-css.com/docs/installation/rsbuild#start-a-new-project to init。
  2. add polyfill: true in panda.config.ts and run build.

JS Framework

React & TS

Panda CSS Version

1.11.1

Browser

Operating System

  • macOS
  • Windows
  • Linux

Additional Information

Because I’m the provider of a component library, other apps may use my components and compile their CSS with @csstools/postcss-cascade-layers or postcss-preset-env. In that case, the reserved @layer reset, base, tokens, recipes, utilities; causes my CSS to be expanded with a large number of unexpected not(#\#) selectors, which makes my styles much higher priority than intended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions