Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Fix #8558
Fix CSS modules ordering by rendering styles first before links. This is needed because in
getStylesForURL
, CSS modules are passed as links (importedCssUrls
) (CSS module has nossrModule.default
):astro/packages/astro/src/vite-plugin-astro-server/css.ts
Lines 34 to 46 in 5ea6ee0
We then put the CSS module links in
links
, and the other styles (global styles) instyles
.astro/packages/astro/src/vite-plugin-astro-server/route.ts
Lines 301 to 330 in 5ea6ee0
Ultimately this creates a tricky situation where we shouldn't actually group head elements this way. Scripts/styles/links should all be in a single array but that takes a larger refactor which we could revisit in the future.
Also, the content rendering runtime also has styles first before links:
astro/packages/astro/src/content/runtime.ts
Line 316 in 5ea6ee0
In most case, non-CSS links could be sorted anywhere though, and I can confirm CSS links are only for CSS modules, so I think this change is harmless. During builds, all CSS are links so there's no ordering issue.
Testing
Added a new integration test.
Docs
n/a. bug fix.