[CLI: vite] server.restart does not trigger plugins to reload
What happened?
When using quasar cli, a restart of the vite server does not trigger a vite plugin reload
What did you expect to happen?
A vite plugin which uses server.restart() will normally reload the full vite config including all of the plugins, this normally is used by plugins to watch for config or .env changes to reload their config, with this broken behavior a full restart of the cli is necessary in dev while making config changes
Reproduction URL
https://github.com/Tofandel/Quasar-Vite-Issue
How to reproduce?
- Create a quasar cli vite project
- Add the following vite plugin
() => {
console.log('Plugin reloaded')
return {
configureServer(server) {
setTimeout(() => {
try {
console.log('Server restarted')
server.restart();
} catch (e) {}
}, 5000);
}
};
}
- Notice that when using
vitethe plugin is reloaded when the server is restarted - Notice when using
quasar devthe plugin is not reloaded
Alternatively clone the reproduction repo and read the readme, which already contains all the minimal reproduction setup
Flavour
Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)
Areas
Quasar CLI Commands/Configuration (@quasar/cli | @quasar/app-vite)
Additional context
PS: I also tried with vite 5 and the v2 alpha of the cli and the issue is also present
From what I gathered the issue can only be solved by providing a config file here https://github.com/quasarframework/quasar/blob/38563c73022990a9b044df042aafacc0924664cd/app-vite/lib/config-tools.js#L111
And letting vite merge the config provided and the given config file
Or by requesting vite to add a callback to retrieve the config
Here is a possible solution for vite https://github.com/vitejs/vite/issues/15783