frandiox / vite-ssr

Use Vite for server side rendering in Node
MIT License
829 stars 92 forks source link

How to prerender routes for production? #105

Closed kslstn closed 3 years ago

kslstn commented 3 years ago

The readme says:

Run vite-ssr build for buildling your app.

I wonder how? The readme doesn't mention installing a CLI.

Context: my production server isn't actually running the application—I want to prerender all routes of my application as html files and put them on basic Apache hosting.

frandiox commented 3 years ago

@kslstn Well it mentions you need to install vite-ssr as an NPM dependency, which also adds a small CLI to your project. As with any other local CLI, you need to run it as a script in package.json, or prefix it with a tool that knows how to find the binary: yarn vite-ssr build, npx vite-ssr build.

In any case, Vite SSR is for rendering routes at runtime in your server (server side rendering). It does not support rendering at build time out of the box, and that's what you seem to be looking for. I would suggest having a look at vite-ssg, which has a similar API to vite-ssr.

kslstn commented 3 years ago

Thank you! npx vite-ssr build is a recognized command (I tried npm vite-ssr build before, but that didn't work).