-
Notifications
You must be signed in to change notification settings - Fork 297
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
Incorrect classnames during SSR #937
Comments
I faced the same issue. Appears that the name of generated class names in a node environment depends on the NODE_ENV environment variable. So, if NODE_ENV === 'production' then it will generate class names like "_1ry5ddd0", and if NODE_ENV === 'development' then it will generate class names like "routes__1ry5ddd0". This is undocumented behavior. I think that it should be added to the documentation. Btw, I resolved the issue by setting the correct NODE_ENV when needed |
The differing There is a config option for classname format, so I do not understand why |
Did a bit of debugging in your reproduction and found that adding |
SvelteKit is pretty similar to the other frameworks mentioned, perhaps this |
Making this user-configurable has been discussed before, so it's likely worth taking another look at it. I'm also curious as to whether #851 will have an affect on this issue, if it ends up getting merged. |
Describe the bug
During server rendering, the target div is rendered with class
routes__1ry5ddd0
, which has no corresponding styles. It hydrates to_1ry5ddd0
, which has the correct styles.The provided example is nothing but the SvelteKit starter (pnpm create svelte@latest) with the vite plugin and a basic style added. It can be easily observed by comparing the hydrated DOM with "view page source" etc. You can also observe the lack of styling using an addon like uBlock Origin or uMatrix or NoScript etc to block JS.
You can clone the repo, run
pnpm install
,pnpm dev
to see the issue.The most outwardly visible symptom is a FOUC, you may or may not be able to see it depending on your setup.
The reproduce conditions are a little complicated, so I've created a table to help. There may be other reproduce conditions I'm not aware of yet, but these work on the repo I provided.
identifiers
vite dev
"short"
vite dev
"debug"
vite build && vite preview
"short"
vite build && vite preview
"debug"
Reproduction
https://github.com/endigma/vanilla-extract-ssr-bug
System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: