-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Initial render to html file #3299
Comments
Sapper is the official, batteries-included solution for something like this. The compiler already can produce a server-side rendered version of a component. This is returned as javascript code which can be run to return html. Returning html code directly from the compiler is not practical, as rendering a component is going to involve executing some user-provided code from the component, and we don't want to be executing arbitrary code - the degree of sandboxing should be up to the user. |
@Conduitry Thanks for your response. I can see why the compiler shouldn't execute arbitrary code. I considered executing the js output and snapshotting the html for the initial render. But, I assume, this snapshot cannot be connected to the JavaScript again at runtime because then the page will be re-generated at runtime. I will have to look again at sapper. It seems to solve my issue but also seems to require a server and I couldn't find a way to generate html files instead. |
Ok, so what I was looking for with sapper was the ability to "export": https://sapper.svelte.dev/docs#Exporting This solves my problem. |
Firstly, this feature could already exist, but after digging for a while I couldn't find it. I asked a question on stackoverflow
Is your feature request related to a problem? Please describe.
Svelte is compiled to both js and css, but not to a html file with the initial render. This means that the initial render has to be performed through JavaScript.
Problems with this:
Describe the solution you'd like
I'd like the ability to also generate a html output which contains the initial render, and contains a
link
andscript
tag to the js and css (this could be configurable). In this situation, the initial render code should be removed from the javascript, and all that's left is the dynamic code.Describe alternatives you've considered
index.html
file and only using Svelte for the dynamic parts. This would be very difficult to do and prevents me from using Svelte for any of the static parts. The dynamic parts would also still not have an initial html render which still has the issues described above, but at least it's better.How important is this feature to you?
Possibly important. If my website(s) grow, I don't want to have the issues I described above, but with a small website, it's not the end of the world for now.
And I don't believe this feature would be particularly difficult to implement.
The text was updated successfully, but these errors were encountered: