fix: non-determinstic options page generation (#137)

* fix: non-determinstic options page generation

* fix: remove console log
This commit is contained in:
Lukas Zenick
2024-03-09 15:01:37 -06:00
committed by GitHub
parent f67280127a
commit d70011016a
3 changed files with 20 additions and 2 deletions

View File

@@ -1 +0,0 @@
src/pages/options/index.html

View File

@@ -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, '<all_urls>'] : HOST_PERMISSIONS,

View File

@@ -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',