fix: crxjs plugin issues

This commit is contained in:
SethBurkart123
2025-03-26 17:00:58 +11:00
parent 68159ddd0e
commit f2b594a13b
9 changed files with 119 additions and 55 deletions
+27
View File
@@ -0,0 +1,27 @@
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,
};
}
}
}
}