-
Notifications
You must be signed in to change notification settings - Fork 31
/
build.js
34 lines (30 loc) · 937 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
let esbuild = require("esbuild");
const path = require("path");
let entries = {
modals: "./static/js/modals/index.js",
};
const isDev = process && process.env && process.env.NODE_ENV === "development";
for (const [key, value] of Object.entries(entries)) {
const options = {
entryPoints: [value],
bundle: true,
minify: !isDev,
nodePaths: [path.resolve(__dirname, "./static/js/src")],
sourcemap: !isDev,
outfile: "static/js/" + key + ".js",
target: ["chrome90", "firefox88", "safari14", "edge90"],
define: {
"process.env.NODE_ENV":
// Explicitly check for 'development' so that this defaults to
// 'production' in all other cases.
isDev ? '"development"' : '"production"',
},
};
esbuild
.build(options)
.then((result) => {
console.log("Built " + key + ".js");
})
// Fail the build if there are errors.
.catch(() => process.exit(1));
}