diff --git a/options.html b/options.html deleted file mode 120000 index 7fd39b9e..00000000 --- a/options.html +++ /dev/null @@ -1 +0,0 @@ -src/pages/options/index.html \ No newline at end of file diff --git a/src/manifest.ts b/src/manifest.ts index 3d3cd6bd..8efde8fa 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -25,7 +25,7 @@ const manifest = defineManifest(async () => ({ name: `${packageJson.displayName ?? packageJson.name}${mode === 'development' ? ' (dev)' : ''}`, version: `${major}.${minor}.${patch}.${label}`, description: packageJson.description, - options_page: 'options.html', + options_page: 'src/pages/options/index.html', background: { service_worker: 'src/pages/background/background.ts' }, permissions: ['storage', 'unlimitedStorage', 'background', 'scripting'], host_permissions: process.env.MODE === 'development' ? [...HOST_PERMISSIONS, ''] : HOST_PERMISSIONS, diff --git a/vite.config.ts b/vite.config.ts index 39ac8f97..c5b1e402 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -42,6 +42,24 @@ const renameFile = (source: string, destination: string): Plugin => { }; }; +const fixManifestOptionsPage = () => ({ + name: 'fix-manifest-options-page', + apply: 'build' as const, + enforce: 'post' as const, + generateBundle(_, bundle) { + for (const fileName of Object.keys(bundle)) { + if (fileName.startsWith('assets/crx-manifest')) { + const chunk = bundle[fileName]; + chunk.code = chunk.code.replace( + /"options_page":"src\/pages\/options\/index.html"/, + `"options_page":"options.html"` + ); + break; + } + } + }, +}); + let config: ResolvedConfig; let server: ViteDevServer; @@ -52,6 +70,7 @@ export default defineConfig({ UnoCSS(), Icons({ compiler: 'jsx', jsx: 'react' }), crx({ manifest }), + fixManifestOptionsPage(), inspect(), { name: 'public-transform',