-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Dev server should not start when plugin config server to be middlewareMode #2094
Comments
I don't know if this should be a supported case, since this is allowing a plugin to replace the actual Vite http server and breaks the fix in #2101 breaks the API contract where I think a better, more explicit usage is to expose a CLI binary from your plugin which starts the server and uses Vite in middleware instead. So instead of |
A CLI bin makes sense, that actually was my first attempt. The reason I switch to the plugin approach is the ViteDevServer not expose the I could create a PR to add some lifecycle hooks options to the dev server if you think it's OK. Another idea is to add a handler to dev server and invoke it in hmr.send, so that the node server would know all the events the hmr sending out. I can create a PR for this as well, see which way you prefer. |
I just realized I could just connect to the WebSocket server created by vite. None of those proposals above aren't needed anymore. |
Describe the bug
When a plugin has the dev server config
middlewareMode
to be true, the CLI should not try to start the dev server. In my case, I would use my own server instead of the vite built-in one.Reproduction
https://github.com/axe-me/dev-server-shouldnt-start
System Info
vite
version: 2.xLogs (Optional if provided reproduction)
error when starting dev server:
Error: Cannot call server.listen in middleware mode.
Solution
dont run
await server.listen()
when resolved config has middlewareMode enabledThe text was updated successfully, but these errors were encountered: