vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.09k stars 6.13k forks source link

Vite moves @import at the top leading to an erroneous layers order #18384

Open ellhn opened 6 days ago

ellhn commented 6 days ago

Describe the bug

I am applying the following css:

@layer reset, bootstrap;
@import url('https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.css') layer(bootstrap);

@layer reset {
  h1 {
    margin-top: 100px;
  }
}

to <h1>Text</h1>

I am expecting: bootstrap layer to take precedence over reset layer and h1 to have a top margin of 0px.

What is actually happening: reset layer takes precedence over bootstrap layer and h1has a top margin of 100px.

Reproduction

https://stackblitz.com/edit/vitejs-vite-ucaxjr?file=main.js,style.css&terminal=dev

Steps to reproduce

No response

System Info

Chrome and Firefox

Used Package Manager

npm

Logs

No response

Validations

stackblitz[bot] commented 6 days ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

sapphi-red commented 5 days ago

This seems to be an upstream issue: https://github.com/postcss/postcss-import/issues/567