Skip to content

[3.x] Stop collecting CSS sub-dependencies during SSR#2937

Merged
pascalbaljet merged 2 commits into
3.xfrom
fix-duplicate-css-imports
Mar 11, 2026
Merged

[3.x] Stop collecting CSS sub-dependencies during SSR#2937
pascalbaljet merged 2 commits into
3.xfrom
fix-duplicate-css-imports

Conversation

@pascalbaljet
Copy link
Copy Markdown
Member

@pascalbaljet pascalbaljet commented Mar 8, 2026

During SSR in dev mode, the CSS collector walks the module graph and injects <link> tags for every CSS module it encounters, including CSS files imported via @import inside other CSS files. Vite plugins like @tailwindcss/vite already compile these sub-dependencies into the parent stylesheet.

The fix stops traversing into a CSS module's own imports, since only root CSS files directly imported by JS modules need their own <link> tags.

Fixes #2935.

@pascalbaljet pascalbaljet added the next major release We need to consider this for the next major release, perhaps because of a breaking change label Mar 8, 2026
@entity
Copy link
Copy Markdown
Contributor

entity commented Mar 9, 2026

Great job! This should link to my initial issue on this, #2935

@pascalbaljet pascalbaljet merged commit c5912cb into 3.x Mar 11, 2026
46 checks passed
@pascalbaljet pascalbaljet deleted the fix-duplicate-css-imports branch March 11, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

next major release We need to consider this for the next major release, perhaps because of a breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants