SSR support out of the box
Is your feature request related to a problem? Please describe. Currently in Vue 2, to build a SSR applications without using a framework like Nuxt.js, a significant amount of configuration is required (webpack, plugins, loaders, etc). Considering the Vite principles, I think it is a great opportunity to provide a way to simulate an SSR context and provide an SSR compatibility build in this framework.
Describe the solution you'd like
It would be interesting to provide a way to make an SSR compatible build from @vue/compiler-ssr
, using something like vite build --ssr
. This could be an alias to ssrBuild()
with default options.
https://github.com/vuejs/vite/blob/32d6341051f26e95c5b2a0859aa0a23ee741b252/src/node/build/index.ts#L337
In addition, it would be interesting to provide a way to inject a context object into an application running in "SSR mode" to simulate an SSR environment. However, I don't know what would be the best way to do this.
Describe alternatives you've considered As an initial idea, none yet.
I don't know if this should be built-in. It could be a plugin (AFAIK @pikax is working on something like that). Or there could a Next/Nuxt like framework built on top of Vite (VitePress is pretty close but only uses the SSR build for static-site generation). We'll see, for now I'll leave it out of Vite core.
I see, a plugin would be nice too. My suggestion came because Vite seems to be a great candidate to support a straightforward way to "convert" a regular SPA application into a SSR one and vice-versa, without depending on third-part framework.