feat: improve dom application method

This commit is contained in:
SethBurkart123
2025-03-27 23:45:04 +11:00
parent f0c5b1dace
commit 5413286f56
6 changed files with 8 additions and 109 deletions
-27
View File
@@ -1,27 +0,0 @@
import { Plugin } from "vite";
export default function shadowDom(): Plugin {
return {
name: 'merge-css-shadow-dom',
enforce: 'post',
apply: 'serve',
transform(src, id) {
if (/\.(css).*$/.test(id)) {
const fn =
"import { updateStyle, removeStyle } from '@/shadowDomUtils.ts';\n";
let updatedSrc = fn + src;
updatedSrc = updatedSrc.replace(
'__vite__updateStyle(',
'updateStyle(',
);
updatedSrc = updatedSrc.replace(
'__vite__removeStyle(',
'removeStyle(',
);
return {
code: updatedSrc,
};
}
}
}
}