mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-05 19:24:39 +00:00
fix: crxjs plugin issues
This commit is contained in:
@@ -34,7 +34,6 @@ export function updateManifestPlugin(): PluginOption {
|
||||
}
|
||||
|
||||
fs.watchFile(manifestPath, () => {
|
||||
console.log('** watchFile **');
|
||||
try {
|
||||
const manifestContents = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
||||
if (manifestContents.web_accessible_resources?.some((resource: any) => resource.use_dynamic_url)) {
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import fs from 'fs';
|
||||
|
||||
export default function touchGlobalCSSPlugin() {
|
||||
return {
|
||||
name: 'touch-global-css',
|
||||
handleHotUpdate({ modules }) {
|
||||
// log all of the staticImportedUrls
|
||||
const importers = modules[0]._clientModule.importers
|
||||
importers.forEach((importer) => {
|
||||
if (importer.file.includes('.css')) {
|
||||
console.log("touching", importer.file)
|
||||
fs.utimesSync(importer.file, new Date(), new Date())
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user