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

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