Skip to content

Commit d8c94bf

Browse files
committed
fix: manifest build error
1 parent cd0cc30 commit d8c94bf

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

vite.config.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
import { defineConfig } from "vite";
2-
import react from "@vitejs/plugin-react";
3-
import svgr from "vite-plugin-svgr";
4-
import { crx } from "@crxjs/vite-plugin";
5-
import manifest from "./manifest.json";
1+
import { defineConfig, Plugin } from 'vite';
2+
import react from '@vitejs/plugin-react';
3+
import { crx } from '@crxjs/vite-plugin';
4+
import manifest from './manifest.json';
5+
6+
const viteManifestHackIssue846: Plugin & { renderCrxManifest: (manifest: any, bundle: any) => void } = {
7+
// Workaround from https://github.com/crxjs/chrome-extension-tools/issues/846#issuecomment-1861880919.
8+
name: 'manifestHackIssue846',
9+
apply: 'build',
10+
renderCrxManifest(_manifest, bundle) {
11+
bundle['manifest.json'] = bundle['.vite/manifest.json']
12+
bundle['manifest.json'].fileName = 'manifest.json'
13+
delete bundle['.vite/manifest.json']
14+
},
15+
}
616

7-
// https://vitejs.dev/config/
817
export default defineConfig({
918
plugins: [
1019
react(),
11-
svgr({
12-
svgrOptions: {
13-
icon: true,
14-
// ...svgr options (https://react-svgr.com/docs/options/)
15-
},
16-
}),
17-
// Build Chrome Extension
20+
viteManifestHackIssue846,
1821
crx({ manifest }),
1922
],
2023
});

0 commit comments

Comments
 (0)