'vite:hmr [no modules matched]

I am trying to get hmr working with vite in my craftcms site, whatever i try i keep getting

vite:hmr [no modules matched] src/scripts/main.ts +0ms

when i run vite in debug mode (vite --debug)

This is my vite config:

import ViteRestart from 'vite-plugin-restart'

export default ({ command }) => ({
  base: command === 'serve' ? '' : '/dist/',
  publicDir: 'non-existent-path',
  build: {
    manifest: true,
    outDir: './web/dist/',
    rollupOptions: {
      input: {
        app: './src/scripts/main.ts',
      },
    },
  },
  server: {
    host: '0.0.0.0',
    port: 3000,
    strictPort: true,
    https: true,
    hmr: {
      host: 'localhost',
      port: 3000,
      path: '/',
    }
  },
  plugins: [
    ViteRestart({
      reload: ['templates/**/*'],
    }),
  ],
})

Where am i going wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source