-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.js
36 lines (34 loc) · 1019 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
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");
build({
entryPoints,
target: "chrome91",
bundle: true,
sourcemap: process.argv.includes("--dev") ? "inline" : false,
minify: !process.argv.includes("--dev"),
outdir: process.argv.includes("--dev") ? "./" : "./",
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");
});