-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.js
40 lines (35 loc) · 1.01 KB
/
esbuild.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
40
const EsBuild = require("esbuild");
const serve = require("./tools/serve");
const postCssPlugin = require("./tools/postCssPlugin");
const dotEnvPlugin = require("./tools/dotEnvPlugin");
console.info("NODE_ENV is set to:", process.env.NODE_ENV);
const BASE_CONFIG = {
entryPoints: {
main: "app.jsx",
},
sourcemap: true,
platform: "browser",
bundle: true,
outdir: "dist",
plugins: [dotEnvPlugin, postCssPlugin],
define: {
ENV: {},
},
};
switch (process.env.NODE_ENV) {
case "development":
serve("dist", 8080, BASE_CONFIG)
.then(server => {
console.log(
`serving STATIC contents from ${server.host}:${server.port}\nserving WEB APP from ${server.host}:8080`
);
})
.catch(() => process.exit(1));
break;
case "test":
EsBuild.build(BASE_CONFIG)
.then(() => console.log("css generated"))
.catch(console.error);
default:
break;
}