-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
38 lines (35 loc) · 980 Bytes
/
build.js
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
import { build as viteBuild } from "vite";
import fs from "node:fs/promises";
import path from "node:path";
const manifestBaseJSON = JSON.parse(
await fs.readFile("./manifests/manifest-base.json", "utf-8")
);
async function build(outDir, manifestSrc) {
await viteBuild({
build: {
target: "esnext",
outDir: outDir,
copyPublicDir: true,
rollupOptions: {
input: {
popup: "src/popup.html",
background: "src/background.ts",
},
output: {
entryFileNames: "src/[name].js",
},
},
},
});
const browserSpecificManifestJSON = JSON.parse(
await fs.readFile(manifestSrc, "utf-8")
);
await fs.writeFile(
path.resolve(outDir, "manifest.json"),
JSON.stringify({ ...manifestBaseJSON, ...browserSpecificManifestJSON })
);
}
await Promise.all([
build("dist/chrome", "./manifests/manifest-chrome.json"),
build("dist/firefox", "./manifests/manifest-firefox.json"),
]);