Files
BetterSEQTA-Plus/lib/shadowDom.ts
T
2025-03-26 17:00:58 +11:00

27 lines
656 B
TypeScript

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,
};
}
}
}
}