-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
44 lines (40 loc) · 1.23 KB
/
Copy pathvite.config.ts
File metadata and controls
44 lines (40 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { viteStaticCopy } from "vite-plugin-static-copy";
import path from "path";
export default defineConfig(({ mode }) => {
const isChrome: boolean = mode === "chrome";
const manifestFile: string = isChrome
? "public/manifest.chrome.json"
: "public/manifest.firefox.json";
const outDir: string = isChrome ? "build/chrome" : "build/firefox";
return {
publicDir: false,
plugins: [
react(),
viteStaticCopy({
targets: [
{ src: manifestFile, dest: ".", rename: "manifest.json" },
{ src: "public/icons", dest: "." },
],
}),
],
build: {
outDir,
rollupOptions: {
input: {
main: path.resolve(__dirname, "index.html"),
background: path.resolve(__dirname, "src/background/index.ts"),
content: path.resolve(__dirname, "src/content/index.ts"),
},
output: {
entryFileNames: (chunkInfo) => {
if (chunkInfo.name === "background") return "background.js";
if (chunkInfo.name === "content") return "content.js";
return "assets/[name]-[hash].js";
},
},
},
},
};
});