Skip to content

[Bug]: @layer rules without a block overwrite previously declared rules #1655

@devongovett

Description

@devongovett

Describe the bug

This input CSS:

@layer b {
  body {
    color: green;
  }
}

@layer b;

results in the first @layer rule being deleted.

Expected behaviour

It should be equivalent to the output from this:

@layer b {
  body {
    color: green;
  }
}

@layer b {}

@layer rules without a block should be treated the same as if they had an empty block.

See this codepen for how it behaves in the browser: https://codepen.io/devongovett/pen/YzoxjPM

Steps to reproduce

see above

Version

latest

Preset

default

Environment

tested in the playground

Package details

https://cssnano.github.io/cssnano/playground/

Additional context

Related upstream bug in Next.js vercel/next.js#68476

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