fix: builds failing in some cases + extension failing to load due to vite legacy api

This commit is contained in:
SethBurkart123
2025-02-11 18:19:07 +11:00
parent 18ffa1b47d
commit 479b2878a9
2 changed files with 28 additions and 10 deletions
+25 -10
View File
@@ -25,17 +25,32 @@ export function updateManifestPlugin(): PluginOption {
console.log('** updated **'); console.log('** updated **');
} }
fs.watchFile(manifestPath, () => { // Implement retry mechanism for file watching
console.log('** watchFile ** '); const watchWithRetry = () => {
const manifestContents = JSON.parse(fs.readFileSync(manifestPath, 'utf8')); if (!fs.existsSync(manifestPath)) {
if (manifestContents.web_accessible_resources.some((resource: any) => resource.use_dynamic_url)) { console.log('Manifest not found, retrying in 1 second...');
const updated = forceDisableUseDynamicUrl(); setTimeout(watchWithRetry, 1000);
if (updated) { return;
server.ws.send({ type: 'full-reload' });
console.log('** updated **');
}
} }
});
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)) {
const updated = forceDisableUseDynamicUrl();
if (updated) {
server.ws.send({ type: 'full-reload' });
console.log('** updated **');
}
}
} catch (error) {
console.log('Error reading manifest, will retry on next change:', error.message);
}
});
};
watchWithRetry();
}); });
}, },
+3
View File
@@ -64,6 +64,9 @@ export default defineConfig({
optimizeDeps: { optimizeDeps: {
include: ['@babel/runtime/helpers/extends', '@babel/runtime/helpers/interopRequireDefault'], include: ['@babel/runtime/helpers/extends', '@babel/runtime/helpers/interopRequireDefault'],
}, },
legacy: {
skipWebSocketTokenCheck: true,
},
build: { build: {
outDir: resolve(__dirname, 'dist', mode), outDir: resolve(__dirname, 'dist', mode),
emptyOutDir: false, emptyOutDir: false,