mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-05 19:24:39 +00:00
feat: update crxjs and remove extra included files
This commit is contained in:
@@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
TEMPORARY FIX FOR CHROME 130+ builds
|
|
||||||
*/
|
|
||||||
|
|
||||||
import path from 'node:path';
|
|
||||||
import fs from 'fs';
|
|
||||||
import { PluginOption } from 'vite';
|
|
||||||
import { ManifestV3Export } from '@crxjs/vite-plugin';
|
|
||||||
|
|
||||||
const manifestPath = path.resolve('dist/chrome/manifest.json');
|
|
||||||
|
|
||||||
export function updateManifestPlugin(): PluginOption {
|
|
||||||
return {
|
|
||||||
name: 'update-manifest-plugin',
|
|
||||||
enforce: 'post',
|
|
||||||
closeBundle() {
|
|
||||||
forceDisableUseDynamicUrl();
|
|
||||||
},
|
|
||||||
|
|
||||||
configureServer(server) {
|
|
||||||
server.httpServer?.once('listening', () => {
|
|
||||||
const updated = forceDisableUseDynamicUrl();
|
|
||||||
if (updated) {
|
|
||||||
server.ws.send({ type: 'full-reload' });
|
|
||||||
console.log('** updated **');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implement retry mechanism for file watching
|
|
||||||
const watchWithRetry = () => {
|
|
||||||
if (!fs.existsSync(manifestPath)) {
|
|
||||||
console.log('Manifest not found, retrying in 1 second...');
|
|
||||||
setTimeout(watchWithRetry, 1000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.watchFile(manifestPath, () => {
|
|
||||||
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();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
writeBundle() {
|
|
||||||
console.log('### writeBundle ##');
|
|
||||||
forceDisableUseDynamicUrl();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function forceDisableUseDynamicUrl() {
|
|
||||||
if (!fs.existsSync(manifestPath)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const manifestContents = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as Awaited<ManifestV3Export>;
|
|
||||||
|
|
||||||
if (typeof manifestContents === 'function' || !manifestContents.web_accessible_resources) return false;
|
|
||||||
if (manifestContents.web_accessible_resources.every((resource) => !resource.use_dynamic_url)) return false;
|
|
||||||
|
|
||||||
manifestContents.web_accessible_resources.forEach((resource) => {
|
|
||||||
if (resource.use_dynamic_url) resource.use_dynamic_url = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
fs.writeFileSync(manifestPath, JSON.stringify(manifestContents, null, 2));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
+1
-1
@@ -36,7 +36,7 @@
|
|||||||
"@babel/plugin-transform-runtime": "^7.26.9",
|
"@babel/plugin-transform-runtime": "^7.26.9",
|
||||||
"@babel/runtime": "^7.26.9",
|
"@babel/runtime": "^7.26.9",
|
||||||
"@bedframe/cli": "^0.0.91",
|
"@bedframe/cli": "^0.0.91",
|
||||||
"@crxjs/vite-plugin": "2.0.0-beta.25",
|
"@crxjs/vite-plugin": "2.0.0-beta.32",
|
||||||
"@types/mime-types": "^2.1.4",
|
"@types/mime-types": "^2.1.4",
|
||||||
"@types/react": "^19.0.10",
|
"@types/react": "^19.0.10",
|
||||||
"@types/react-dom": "^19.0.4",
|
"@types/react-dom": "^19.0.4",
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
],
|
],
|
||||||
"web_accessible_resources": [
|
"web_accessible_resources": [
|
||||||
{
|
{
|
||||||
"resources": ["*/*", "resources/*", "seqta/utils/migration/migrate.html", "plugins/built-in/globalSearch/*"],
|
"resources": ["resources/icons/*", "seqta/utils/migration/migrate.html"],
|
||||||
"matches": ["*://*/*"]
|
"matches": ["*://*/*"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import { join, resolve } from 'path';
|
import { join, resolve } from 'path';
|
||||||
|
|
||||||
import { updateManifestPlugin } from './lib/patchPackage';
|
|
||||||
import touchGlobalCSSPlugin from './lib/touchGlobalCSS';
|
import touchGlobalCSSPlugin from './lib/touchGlobalCSS';
|
||||||
import InlineWorkerPlugin from './lib/inlineWorker';
|
import InlineWorkerPlugin from './lib/inlineWorker';
|
||||||
import { base64Loader } from './lib/base64loader';
|
import { base64Loader } from './lib/base64loader';
|
||||||
@@ -9,7 +8,6 @@ import type { BuildTarget } from './lib/types';
|
|||||||
import ClosePlugin from './lib/closePlugin';
|
import ClosePlugin from './lib/closePlugin';
|
||||||
|
|
||||||
import million from "million/compiler";
|
import million from "million/compiler";
|
||||||
//import MillionLint from '@million/lint';
|
|
||||||
|
|
||||||
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
||||||
|
|
||||||
@@ -27,7 +25,6 @@ const targets: BuildTarget[] = [
|
|||||||
|
|
||||||
const mode = process.env.MODE || 'chrome'; // Check the environment variable to determine which build type to use.
|
const mode = process.env.MODE || 'chrome'; // Check the environment variable to determine which build type to use.
|
||||||
//const sourcemap = (process.env.SOURCEMAP === "true") || false; // Check whether we want sourcemaps.
|
//const sourcemap = (process.env.SOURCEMAP === "true") || false; // Check whether we want sourcemaps.
|
||||||
|
|
||||||
export default defineConfig(({ command }) => ({
|
export default defineConfig(({ command }) => ({
|
||||||
plugins: [
|
plugins: [
|
||||||
base64Loader,
|
base64Loader,
|
||||||
@@ -36,12 +33,10 @@ export default defineConfig(({ command }) => ({
|
|||||||
emitCss: false
|
emitCss: false
|
||||||
}),
|
}),
|
||||||
million.vite({ auto: true }),
|
million.vite({ auto: true }),
|
||||||
//MillionLint.vite(), /* enable for testing and debugging performance */
|
|
||||||
crx({
|
crx({
|
||||||
manifest: targets.find(t => t.browser === mode.toLowerCase())?.manifest ?? chrome.manifest,
|
manifest: targets.find(t => t.browser === mode.toLowerCase())?.manifest ?? chrome.manifest,
|
||||||
browser: mode.toLowerCase() === "firefox" ? "firefox" : "chrome"
|
browser: mode.toLowerCase() === "firefox" ? "firefox" : "chrome"
|
||||||
}),
|
}),
|
||||||
updateManifestPlugin(),
|
|
||||||
touchGlobalCSSPlugin(),
|
touchGlobalCSSPlugin(),
|
||||||
...(command === 'build' ? [ClosePlugin()] : [])
|
...(command === 'build' ? [ClosePlugin()] : [])
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user