Skip to content

@import with layer() places media queries outside of the layer #495

@mvsde

Description

@mvsde

I created a basic reproduction case here: https://github.com/mvsde/postcss-cascade-layers

What’s happening:

I @import another CSS file with layer(test). That other file includes a media query.

After running this through PostCSS with the postcss-import plugin I get the following output:

@layer test {

body {}
}

@media (min-width: 50rem) {
  body {}
}

@layer test {

p {}
}

Note how the layer test is closed before the media query and “re-opened” afterwards.

I think the expected output should be something like:

@layer test {

body {}

@media (min-width: 50rem) {
  body {}
}

p {}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions