-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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 is included in SSR builds #8859
Comments
Note that it doesn't break anything, so it's low priority. But, in order to reduce confusion and build time, we should remove the unnecessary CSS living in SSR builds. |
This is more important than I initially thought. Because it considerably increases the bundle size of server-side builds, which is critical for edge platforms such as Cloudflare Workers. A workaround would be to use a code pruning tool that removes unused variables: AFAICT that should do the trick to remove the CSS form the server build. @benmccann I think SvelteKit may want to know about this. |
This is affected by #8278. This implementation depends on minifier to remove these unused code. But minifying is not enabled for SSR build by default (I didn't know this). For a workaround, setting I think changing this line to disable minify only for vite/packages/vite/src/node/build.ts Line 247 in d93ac8e
About v2, I think I need to revert #8278 (#8471). There is another issue (#8819) related to #8278. @patak-dev |
@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 #8454) |
That may explain #8715. (My guess was that there was a problem with too much memory consumption. Note that it happened with the Vite 3 alphas but not with the Vite 3 betas, I don't know why.)
👍 |
Describe 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
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: