-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
37 lines (35 loc) · 1.04 KB
/
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
const fs = require("fs");
const { build } = require("esbuild");
const { sassPlugin } = require("esbuild-sass-plugin")
const entryPoints = [];
const checkEntry = (path) => {
if (fs.existsSync(path)) entryPoints.push(path);
};
checkEntry("src/index.tsx");
checkEntry("src/startup_script.ts");
build({
entryPoints,
target: "chrome91",
bundle: true,
sourcemap: process.argv.includes("--dev") ? "inline" : false,
minify: !process.argv.includes("--dev"),
outdir: process.argv.includes("--dev") ? "./" : "./dist",
define: {
DEBUG: process.argv.includes("--dev").toString(),
},
watch: process.argv.includes("--watch")
? {
onRebuild(err, result) {
console.log("Rebuilding");
if (err) {
console.warn(err.message);
} else if (result) {
console.log("Build success");
}
},
}
: undefined,
plugins: [sassPlugin()],
}).then(() => {
console.log("Build success");
});