-
Notifications
You must be signed in to change notification settings - Fork 48
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
Node Server doesn't start automatically #85
Comments
Hi @xmuller. I have read through and tried to apply your method, but I think it has some problems. I only want to connect to the db when fastify is ready.
So your way the function "onReady" will not be executed, your way only executes functions that run directly in the file "config.appPath" |
Hello ! Yes, to be fair I didn't think a lot about the code I wrote. In the end I don't use this plugin. I do the classic build and nodemon with https://github.com/SukkaW/rollup-plugin-swc. As far as my research goes, the only benefit of another plugin would be to have a dev environnement that integrate the HMR API with one or many backend. |
By default the only way the vite server load modules is from the handler given here: https://github.com/axe-me/vite-plugin-node/blob/main/packages/vite-plugin-node/src/server/fastify.ts based on the viteNodeApp that is exported from your main file. If you want to load execute something when fastify is ready you can try to call it yourself first.
There is a high chance that this will not work. That why I choose to not bother me and just compile and run which is as fast as the method proposed in this plugin. |
I have a Node app that doesn’t listen at all, so I needed a way to start it when run via
|
Sorry I'm late to the party. I just added an |
closing this for now, feel free to reopen it if you have any questions. |
Hello @axe-me! I'm facing a similar problem. I'm trying to use this together with Nest (
But the application finally starts (log: What can be done in such a situation? |
Description
I've been using
vite-plugin-node
with express and both REST and GraphqlAPI for few month and it works quite well so far.But there is one thing that annoy me and I wonder if there is a way through config to do something.
Basically when I use
vite dev
, I get the vite logBut probably because of the HMR, the server and code are only executed when a query is done.
So starting the server, only start vite, not really the node server, it need a query to finally notice and start the API.
It's really annoying from a dev perspective because:
Is there a way to force vite to execute the
viteNodeApp
automatically on startup?I thought about adding some healthcheck logic around to request a useless endpoint like
/health
.But it felt like an ugly workaround.
The text was updated successfully, but these errors were encountered: