-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.mjs
executable file
·48 lines (43 loc) · 1006 Bytes
/
build.mjs
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
45
46
47
48
#!/usr/bin/env node
/* eslint-env node */
import * as esbuild from "esbuild";
const arg = process.argv[2];
const mode = process.env.MODE;
const browser = process.env.BROWSER;
const options = {
entryPoints: [
"./src/background.js",
"./src/content.js",
"./src/popup/index.js",
"./src/popup/index.html",
"./src/popup/index.css",
"./src/options/index.js",
"./src/options/index.html",
"./src/options/index.css",
{
in: `./src/manifest.${browser}.json`,
out: "manifest",
},
{
in: "./icon.png",
out: "icon",
},
],
loader: {
".html": "copy",
".css": "copy",
".json": "copy",
".png": "copy",
},
outbase: "src",
outdir: arg === "watch" ? "./build" : arg,
target: "es6",
bundle: true,
allowOverwrite: true,
minify: mode === "production",
sourcemap: mode === "development",
};
if (arg === "watch") {
const ctx = await esbuild.context(options);
await ctx.watch();
} else await esbuild.build(options);