-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Imported CSS getting duplicated in dev server #5857
Comments
This comment was marked as outdated.
This comment was marked as outdated.
The original issue here is fixed by #5917. The |
just for clarity, i did not touch the i can open an issue in vite for the layer issue, but i can't seem to reproduce it in vanilla vite |
I believe the issue here is that with devSourcemaps it was creating double styles, as in the style tag inline and also the style src referenced. Which caused an issue with layer directive because styles were duplicated in the page. Considering that, I don’t think it would be repro without devSourcemaps. |
but it is reproducible in my two stackblitz links above |
O yes, that makes sense. Astro is doing the same thing irrespective of devSourcemaps I believe. But the issue would be fixed without double styles. That makes sense why you can’t reproduce in vanilla vite. I’m pretty sure it’s the same issue but I would have to take a closer look when this PR is merged, can you try with the PR? |
Yep, I will add another test to confirm that your first repro doesn't regress.
For this one, I'm seeing some strange output that leads me to believe this is an upstream issue... But I suppose it's possible there's something happening on our end? I'll have to look into this more if you can't repro in plain Vite. @layer A, B;
@media (A){
@layer vite--anon-layer-4076b8fe-0{
body {
font-family: system-ui;
display: grid;
place-items: center;
background-color: tomato;
}
}
}
@layer B {
:where(body) {
background-color: hotpink;
}
} |
@natemoo-re So, testing on that's an improvement! i'd guess the one duplication left is because of the module graph thing you mentioned.
|
update: actually the layer thing was partly because of invalid syntax on my end 🤦 there should be no space between - @import '../styles.css' layer (A);
+ @import '../styles.css' layer(A); see final updated stackblitz: https://stackblitz.com/edit/github-fkhp2c-kkhdqq the duplication happens only in dev now, not prod, and the layer gets stripped only in astro, not vite.
sorry about all the confusion! let me know if i can clarify anything. |
So what's going here is:
So unfortunately there isn't a way to really do what you'd like us to do and not treat this as a dependency. Going to leave this open for now, but I don't see any possible solution here. We could revisit why we add |
why are SSR/FOUC is not really a concern in the dev server, so i think vite should handle all of it. and prod seems to behave correctly after #5917 |
Issue still exists with |
I can't reproduce this in [email protected], so I'll close this. |
Huh, it does appear to be fixed in 4.15 at least in my initial testing, which is great news! 🚀 I'll test against some more repos and report back if there is still an issue. |
What version of
astro
are you using?1.9.2
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
Windows / Stackblitz
Describe the Bug
Original description
When importing a css file (local or npm.
@import
orimport
. doesn't matter), the styles get duplicated anywhere from 2-4 times.Doesn't seem to affect prod build, and doesn't seem to affect styles defined in the same file.
Possibly related issues: #5817, #5834, #5715
When importing a stylesheet into a cascade layer, the styles get incorrectly duplicated outside the layer. See comment below: #5857 (comment)
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-fkhp2c-kkhdqq
Participation
The text was updated successfully, but these errors were encountered: