-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Support server entry — $ vite path/to/server.js
/ vite.config.js#server
.
#6394
Comments
vite path/to/server.js
/ vite.config.js#server
.$ vite path/to/server.js
/ vite.config.js#server
.
Sounds similar to https://github.com/antfu/vite-node ? |
@mquandalle Yes, but it needs to be built into Vite for brillout/research#3. |
This would be awesome! I was just about to post about wanting to create a plugin that creates a server in middleware mode (ssr) and either works with Vite or allows you to replace the server with your own. This issue seems to fit that bill. In my scenario, I don't want the user to have to define a server.js though. I want it to be provided by my custom plugin out of the box. Sort of on the same topic, but could it be possible to allow for a custom index.html (like ssr mode allows) but allow it to be passed to the vite dev server (instead of it assuming there's a local file at the root)? The only real reason I use ssr mode is because, similar to abstracting away server.js from users, I want to do the same for the index.html and entry.js. I've already accomplished this via my own custom package that people need to use. Would love to be able to do these things via a plugin or natively with Vite. |
Clear and concise description of the problem
Vite does not support server entries.
For example, the
playground/ssr-vue/server.js
file is not processed by Vite which means:import.meta.env
.ts-node
).server.js
then the user has to manually stop and re-start the server.Suggested solution
We add an argument to the CLI command
vite
.The argument is optional and if omitted Vite behaves as it does today (it starts Vite's built-in dev server).
The whole
vite.loadSSRModule
dance would be taken care of.We can even consider adding support for HMR and, if HMR is not applicable, to automatically reload the server by killing
process.env.PORT
with e.g. kill-port. (It's a common convention to useprocess.env.PORT
as server port.)The user can also define the server entry with
vite.config.js#server
.# No need to specify the server entry here $ vite
Alternative
No response
Additional context
This ticket is part of Vite Server RFC.
Validations
The text was updated successfully, but these errors were encountered: