-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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: {
name: 'myplugin',
configureServer(server, mode) {
if (mode === 'preview') {
//...
}
}
} or {
name: 'myplugin',
apply: 'preview', // normal plugins won't apply to preview unless set explictly
configureServer(server) {
//...
}
} |
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
configureServer
but 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 build
also works. The only command that doesn't work is$ vite preview
because 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.