You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
594 B
26 lines
594 B
2 years ago
|
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 [];
|
||
|
|
||
|
modules.forEach((m) => {
|
||
|
if (!m.url.match(/\.(css|less)/)) {
|
||
|
m.importedModules = new Set();
|
||
|
m.importers = new Set();
|
||
|
}
|
||
|
});
|
||
|
|
||
|
return modules;
|
||
|
},
|
||
|
};
|
||
|
}
|