Open kurtextrem opened 7 years ago
I like this idea and had thought of the same thing; in fact, if done right i think it could actually make this thing even faster (obviously depending on what you need for prerender in the app shell/index.html)
My plan was to create an npm script called 'prerender' or 'static' that would effectively run the root.js route and generate a static index.html file in /build.
I'd love to hear your thoughts & expectations to help me build this out.
cheers!
Sounds exactly what I had in mind 👍 Actually I've asked the author of Preact, but he didn't answer: https://twitter.com/kurtextrem/status/833217690059825152 - maybe you could push?
Ah - sorry for.missing those tweets, I don't scan for #react tweets, only #preact ones. I think a lot of people use static-site-generator-webpack-plugin.
I actually set this up for preactjs.com but ended up switching back to just prerendering the App Shell instead of the whole app. If you want to see what the full page-by-page prerendering looked like though, it's on an ssr
branch:
Thank you Jason, that's exactly what I'm looking for. Great to hear that we're not the only one looking for such things :)
What made you switch back? Were there any drawbacks?
The frontend dynamically fetches markdown files from a content/
directory, and shows a loading spinner while doing so. When I pre-rendered everything with seeded data, it would just immediately rip out the prerendered markdown and replace it with a spinner. I might revisit though, it's possible appending the source markdown as data to the page (via a <script>
tag) would work.
Is it somehow possible to make a static build, using preact to string and then upload it to a server that doesn't run node?