axe-me / vite-plugin-node

Vite plugin to run your node dev server with HMR!
1k stars 48 forks source link

It disrupts the static serving of Vite #70

Open branaway opened 1 year ago

branaway commented 1 year ago

Hi,

The Vite can serve static assets in the public dir by default. This feature would be disrupted with the presence of this plugin in the Vite.config.js. Any saves here?

jvdl commented 3 months ago

@branaway I know this might be a bit late for you, but hopefully still useful for you and others in new projects :-)

I found myself in the same boat in that I wanted to run Vite for my frontend as well as my backend. To allow them both to serve independently I decided to spin up 2 Vite servers, one for the UI and one for the API. I've put my template/boilerplate into a repo that will hopefully be a helpful reference.

The idea behind running them as separate servers is that it closely resembles the fact that they can be deployed independently. The UI can be built for production and deployed to any static asset hosting service and the API can be deployed to whatever your preferred hosting solution is, with suitable proxy/domain configuration.