2021-03-17 00:10:16 +08:00
|
|
|
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 [];
|
2021-04-19 23:40:59 +08:00
|
|
|
|
2021-03-17 00:10:16 +08:00
|
|
|
modules.forEach((m) => {
|
2021-04-19 23:51:43 +08:00
|
|
|
if (!m.url.match(/\.(css|less)/)) {
|
|
|
|
m.importedModules = new Set();
|
|
|
|
m.importers = new Set();
|
|
|
|
}
|
2021-03-17 00:10:16 +08:00
|
|
|
});
|
2021-04-19 23:40:59 +08:00
|
|
|
|
2021-03-17 00:10:16 +08:00
|
|
|
return modules;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|