-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.config.js
More file actions
51 lines (45 loc) · 957 Bytes
/
esbuild.config.js
File metadata and controls
51 lines (45 loc) · 957 Bytes
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
41
42
43
44
45
46
47
48
49
50
51
import * as esbuild from "esbuild";
import { glsl } from "esbuild-plugin-glsl";
/* - Setup */
const env = process.env.NODE_ENV;
const production = env === "production";
const CONFIG = {
PORT: 8000,
ENTRY: ["src/app.js"],
SERVE_DIR: "dist",
OUT_DIR: "dist",
BUILD_DIR: "build",
};
/* -- Plugins */
const plugins = [
glsl({
minify: production,
}),
];
const loader = {
".png": "dataurl",
".webp": "dataurl",
".glb": "dataurl",
};
const ctx = await esbuild.context({
bundle: true,
entryPoints: CONFIG.ENTRY,
outdir: production ? CONFIG.BUILD_DIR : CONFIG.OUT_DIR,
minify: production,
sourcemap: !production,
target: production ? "es2019" : "esnext",
plugins,
loader,
});
if (production) {
await ctx.rebuild();
ctx.dispose();
} else {
await ctx.watch();
await ctx
.serve({
servedir: CONFIG.SERVE_DIR,
port: CONFIG.PORT,
})
.then(() => console.log("http://localhost:8000/app.jss"));
}