quasar icon indicating copy to clipboard operation
quasar copied to clipboard

[CLI: vite] server.restart does not trigger plugins to reload

Open Tofandel opened this issue 1 year ago • 2 comments

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?

  1. Create a quasar cli vite project
  2. Add the following vite plugin
() => {
  console.log('Plugin reloaded')
  return {
    configureServer(server) {
      setTimeout(() => {
        try {
          console.log('Server restarted')
          server.restart();
        } catch (e) {}
      }, 5000);
    }
  };
}
  1. Notice that when using vite the plugin is reloaded when the server is restarted
  2. Notice when using quasar dev the 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

Tofandel avatar Feb 01 '24 19:02 Tofandel

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

Tofandel avatar Feb 01 '24 20:02 Tofandel

Here is a possible solution for vite https://github.com/vitejs/vite/issues/15783

Tofandel avatar Feb 02 '24 10:02 Tofandel