CSS is included in SSR builds
See original GitHub issueDescribe the bug
CSS is included in SSR builds, which is unexpected: CSS is useless on the server-side. (You can actually see that the CSS included in the SSR build is unused.)
Reproduction
https://github.com/brillout/vite-bug-css-included-in-ssr-build
System Info
System:
OS: Linux 5.10 Debian GNU/Linux 10 (buster) 10 (buster)
CPU: (2) x64 Intel(R) Celeron(R) N4020 CPU @ 1.10GHz
Memory: 413.73 MB / 2.71 GB
Container: Yes
Shell: 5.0.3 - /bin/bash
Binaries:
Node: 18.0.0 - ~/.config/nvm/versions/node/v18.0.0/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.6.0 - ~/.config/nvm/versions/node/v18.0.0/bin/npm
Browsers:
Firefox: 97.0.1
Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Adding CSS to React SSR Components - Stack Overflow
I am trying to add CSS to my component built in React using SSR, but I am unable to do so. Things I've...
Read more >Adding style to Server-Side rendering and automating the ...
Adding style to Server-Side rendering and automating the build process ... Creating a project for SSR from scratch (including writing babel ...
Read more >React Server Side Rendering (SSR) with Express and CSS ...
I was learning React Server Side Rendering (SSR) recently. Lots of tutorials have so many new libraries and have a large codebase.
Read more >Styles & CSS - Astro Documentation
Learn how to style components in Astro with scoped styles, external CSS, and tooling like ... Styles won't be automatically included in the...
Read more >JavaScript-less Static SSR using Styled Components
How to build a completely static site using React and Styled Components. ... How do we extract the styles into a CSS file...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sapphi-red I tagged you in a thread in discord started by @bluwy, that also found memory issues possibly related to #8278. I think we should revert v2, yes, PR welcome if you can.
And for v3, I don’t know about the implications of forcing minification. Maybe we should revert it too and then test with more time for v3.1
Also, I wonder if we could bail out of CSS a lot sooner in SSR so we don’t need to process them (in the same lines of https://github.com/vitejs/vite/pull/8454)
Closing as it is fixed by https://github.com/vitejs/vite/pull/8874 (v2) and https://github.com/vitejs/vite/pull/8896 (v3).