emosheeep / vite-plugin-virtual-mpa

Out-of-box MPA plugin for Vite, generate multiple entries using only one template.
https://stackblitz.com/~/github.com/emosheeep/vite-plugin-virtual-mpa
MIT License
112 stars 15 forks source link

Add ability to always write the the HTML file even with the dev server #72

Open hopperd opened 1 month ago

hopperd commented 1 month ago

I would like to have the HTML file written out even when devServer is running similar to a production build.

The use case is that I'm using a Java/Spring application that looks for these files to render them as Thymeleaf templates. This works perfect with a production build, but since the dev builds don't write the file the templates are not found.

emosheeep commented 1 month ago

I think maybe you can get files you want through http request when starting with devServer? It doesn't seem like a common solution.

hopperd commented 1 month ago

Do you mean this doesn't feel like something that is valuable to add to this plugin or the solution of doing during the devServer starting phase doesn't seem common?

emosheeep commented 1 month ago

yeah, it sounds like vite build --watch

hopperd commented 1 month ago

Ah ok, that does appear to write the files out, but doesn't appear to listen on any port for some reason so HMR still isn't working.

hopperd commented 1 month ago

I kind of got it working using concurrently "vite" "vite build --watch". Thanks for pointing me in the right direction and great job on the plugin

hopperd commented 1 month ago

Unfortunately this doesn't actual let HMR work. One has to still reload the entire page for this to work correctly which isn't as ideal as HMR. Basically looking for similar support for https://github.com/vitejs/vite/discussions/6108.