-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
39 lines (33 loc) · 844 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
39
const fs = require("fs");
const esbuild = require("esbuild");
const isProduction = process.env.NODE_ENV === "production";
function copyFiles() {
const files = [
{ from: "src/app/index.html", to: "dist/index.html" },
{ from: "assets/favicon.ico", to: "dist/favicon.ico" },
];
files.forEach(({ from, to }) => fs.copyFileSync(from, to));
}
const options = {
entryPoints: ["src/app/index.jsx", "src/app/lib/worker.js"],
outdir: "dist",
bundle: true,
sourcemap: !isProduction,
minify: isProduction,
watch: isProduction
? false
: {
onRebuild(err) {
if (err) {
console.error(err);
return;
}
copyFiles();
},
},
logLevel: "info",
};
esbuild
.build(options)
.then(() => isProduction && copyFiles())
.catch(() => process.exit(1));