feat: new hook configurePreviewServer#7658
Conversation
3521d97 to
64e560e
Compare
|
This would make an SSR plugin doable without making a wrapper CLI for Vite! Awesome feature! 🔥🚀 |
|
Instead of a new hook, I am thinking we could either: or |
I share the sentiment and it was actually my initial implementation. But I'm not sure how we could make it work with TypeScript: type PreviewServer = { middlewares: Connect.Server, httpServer: http.Server }
{
name: 'myplugin',
// Is `server` a `ViteDevServer` or a `PreviewServer`?
configureServer(server) {
//...
}
}Setting
Exactly. This is actually what is happening with vps: https://github.com/brillout/vite-plugin-ssr/blob/0.4.0/examples/react/package.json — note how the vite CLI is used together with |
b1ca464 to
5d55913
Compare
|
Rebased & added some code comments. |
|
Note: This PR is in the team discussion board. We'll try to get to it soon! |
|
@brillout we discussed today this proposal, we think it is a good idea. Would you rebase the PR? Then we are good to merge it. |
Co-authored-by: Jeff Yang <32727188+ydcjeff@users.noreply.github.com>
5d55913 to
38c7701
Compare
|
Done. Btw. I'm not forgetting to resurrect the
Thanks for the update, that was super helpful :-). |
I couldn't contain myself: #8061 :-). |
Co-authored-by: Rom <git@brillout.com>
Description
Same than
configureServerbut for the preview server.Additional context
We are building frameworks on top of vps and we are aiming for zero-config developer experiences. For example:
To make this work we need to add the vps and Telefunc middlewares to Vite's dev server which we can achieve by using
configureServer(). The$ vite buildalso works. The only command that doesn't work is$ vite previewbecause there are currently no way to inject middlewares to the preview server.What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).I considered adding tests, but the only meaningful tests I could think of were e2e tests. I think a new e2e test would be too much; it would increase the number of playgrounds without adding enough value to be justified. The vps test suite will include a test, so we'll catch problems at latest when running Vite against vps's test suite.