Which command to run in production?
lourot opened this issue · 4 comments
Let's say I want to deploy on Netlify. I could either:
- use
{ prerender: true }
and let Netlify statically servedist/client/
, or - tell Netlify to run
npm run preview
(is this really meant for production?), or - is there a third way?
Thanks :)
👍 Yes, you can do both: build & pre-render locally then upload dist/client/
to Netlify, or let Netlify build & pre-render your app on their build pipeline. You can also run prerender()
programmatically. Some users, for example, use this to re-run pre-rendering upon some API call.
FYI we have a Q&A over at GitHub Discussion, see vikejs/vike#526.
With vite-plugin-ssr
there is an npm run prod
command that does ts-node ./server/index.ts
, but with Vike there is neither a prod
command nor a ./server/index.ts
file, so I don't understand how to run the prod server. It doesn't feel like vite-plugin-ssr's GitHub Discussions are the right place to discuss as this seems to be a Vike-specific problem. I don't see GitHub discussions on this repo. What do you think?
(and from what I understand, vite preview
is not meant for production)
See https://github.com/brillout/vite-plugin-ssr/tree/dev/examples/vike-react.
Basically: vike-react
implements renderer/
on your behalf, so that you don't have to implement it yourself. Everything else stays the same, including deployement. For example: https://github.com/brillout/vite-plugin-ssr/tree/main/examples/cloudflare-workers-react-v1.