-
-
Notifications
You must be signed in to change notification settings - Fork 435
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
Svelte SSR does not render component CSS #1760
Comments
include component CSS in head, fixes inertiajs#1760
there is a PR #1761 |
We should start brainstorming how this can be fixed for Svelte 5. Since Svelte 5's |
If anyone is in a position like me and wants to preload the CSS when using SSR with Svelte 5, here is what I'm currently doing:
Here's an example for Rails: def vite_global_style_tag
if Rails.env.test?
vite_folder = "vite-test"
else
vite_folder = "vite"
end
manifest_path = Rails.root.join("public", vite_folder, ".vite", "manifest.json")
return "" unless File.exist?(manifest_path)
manifest = JSON.parse(File.read(manifest_path))
file = manifest["style.css"]["file"]
stylesheet_link_tag("/#{vite_folder}/#{file}", media: "all")
end This file will contain all global and component CSS. This isn't optimal for large apps, but have to start somewhere. Svelte 5 recently also introduced the |
#1970 has been merged, and SSR should now work correctly with both Svelte 4 and 5. You can refer to the Svelte playgrounds as examples. Let me know if you run into any issues! |
This shouldn't be closed as this is still a problem with Svelte 5. Or can you point me to where in the playground example you are rendering the component CSS during SSR? |
@buhrmi If you're still experiencing this issue with Svelte 5, please feel free to reopen the PR. Additionally, providing a reproducible repository would help us investigate. |
@pedroborges just add any CSS in a <style> tag to any Svelte component and you will see the style being applied AFTER the initial render. I see that the Svelte 5 playground code has no component styles whatsoever, so I guess that's why you're not experiencing it. Let me know if you still require a repo. |
Also, the PR was only for Svelte 4. As I've stated here, we are still lacking a solution for this problem for Svelte 5. |
Looks like 3 months ago they added the |
okay I can confirm that the |
Version:
@inertiajs/svelte
version: 1.0.14Describe the problem:
When using Svelte SSR, the server side renderer does not render the component CSS, which results in content shifting around once the CSS is loaded via Javascript.
The text was updated successfully, but these errors were encountered: