-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
tsup.config.ts
40 lines (36 loc) · 975 Bytes
/
tsup.config.ts
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
import { defineConfig } from "tsup";
import { copyFile } from "node:fs/promises";
const TARGET = process.env.TARGET as "chrome" | "firefox";
export default defineConfig({
clean: true,
entry: [
"src/background.ts",
"src/blocked.ts",
"src/options.ts",
],
env: { TARGET },
outDir: `dist/${TARGET}`,
target: "es2022",
format: "esm",
treeshake: true,
noExternal: ["dayjs"],
esbuildOptions(options) {
options.chunkNames = "chunks/[name]-[hash]";
},
onSuccess: () => new Promise((resolve, reject) => {
const files = [
"icon_32.png",
"icon_128.png",
"common.css",
"blocked.css",
"blocked.html",
"options.css",
"options.html",
`manifest-${TARGET}.json`,
];
const copyFilesPromises = files.map((file) => (
copyFile(`public/${file}`, `dist/${TARGET}/${file.replace(`-${TARGET}`, "")}`)
));
Promise.all(copyFilesPromises).then(() => resolve()).catch(reject);
}),
});