OFFLINE-GmbH / oc-vite-plugin

Vite integration for October CMS
MIT License
23 stars 9 forks source link

How do you get HMR to work with pages, layouts and partials? #6

Closed roulendz closed 5 months ago

roulendz commented 1 year ago

How do you get HMR to work with pages, layouts and partials? Thank you.

anik1ng commented 5 months ago

If anyone is looking for how to do monitoring for *.htm files, here is an example:

// ...

export default defineConfig({

// ...

  plugins: [
    {
      name: 'watcher-html',
      configureServer(server) {
        server.watcher.add(resolve(__dirname, '**/*.htm'));
        server.watcher.on('all', (event, file) => {
          if (file.endsWith('.htm')) {
            server.ws.send({type: 'full-reload'});
          }
        });
      }
    },
  ],

// ...

});

Just add this code to your vite.config.js.