Blame view

build/vite/plugin/hmr.ts 594 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
import type { Plugin } from 'vite';

/**
 * TODO
 * Temporarily solve the Vite circular dependency problem, and wait for a better solution to fix it later. I don't know what problems this writing will bring.
 * @returns
 */

export function configHmrPlugin(): Plugin {
  return {
    name: 'singleHMR',
    handleHotUpdate({ modules, file }) {
      if (file.match(/xml$/)) return [];
14
15
      modules.forEach((m) => {
Vben authored
16
17
18
19
        if (!m.url.match(/\.(css|less)/)) {
          m.importedModules = new Set();
          m.importers = new Set();
        }
20
      });
21
22
23
24
25
      return modules;
    },
  };
}