-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
CSS Sourcemap Duplication of References in Dev #5817
Comments
This happens because Astro injects your styles on the server to avoid FOUC, then Vite picks up the rendering on the client. In order to fix this we would need to come up with a new approach than this two-stage approach. Does this cause any noticeable issues other than being irritating when modifying styles in the browser? |
@natemoo-re I think you had an issue open for this already? Sorry, I couldn't find it at the time. Feel free to close then. I've experienced no other issues otherwise. |
Can this be configured at the very least. I wouldn't care as much about a FOUC during dev, but not having source maps is a non-starter for anything greater than toys. All I'm seeing is |
I've diagnosed the issue at least: With this in my astro.config.mjs:
There's an issue with the matching of
And here:
I did a diff between the values, and there are some odd differences between what should be the same files. It's possible extensions or something else is calling the values to be different. A simple fix is to replace Looks like this would be have to be pushed upstream to the point where the style elements are injected (by Vite?) to add an |
Thanks for the investigation @gvkhna! With your help, I was able to track down what was going on here—looks like there were situations where the exact content didn't match and the duplicate styles weren't being handled properly. I've opened #5917 which should fix this! We'll now match on the actual fileId instead of the text content. Also confirmed that it works with |
* fix(#5817): remove duplicate CSS in dev * chore: add changeset Co-authored-by: Nate Moore <nate@astro.build>
* fix(#5817): remove duplicate CSS in dev * chore: add changeset Co-authored-by: Nate Moore <nate@astro.build>
What version of
astro
are you using?1.9.1
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
Mac
Describe the Bug
This is part of an old closed issue that needs addressing since Astro 1.0.0-beta42.
Original issue: #3647
I thought it might work itself out with future Astro versions. Even with Astro 2 beta which utilizes Vite v4, the issue persists.
With CSS sourcemaps enabled, there is duplicate CSS being referenced from both the css file and page file. This can make debugging css extremely tedious. I thought maybe it was a Vite bug. After using Vite as standalone compiler and Sveltekit 1.0, that doesn't seem to be the case as there is no CSS sourcemap duplication with these libraries.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-g7v2dq
Participation
The text was updated successfully, but these errors were encountered: