-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.js
43 lines (41 loc) · 1.05 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
41
42
43
import esbuild from "esbuild";
import packageJson from "./package.json" with { type: "json" };
const isDev = process.env.NODE_ENV === "development";
async function watch() {
let ctx = await esbuild.context({
entryPoints: ["./src/index.tsx"],
minify: !isDev,
outfile: isDev ? "./build/bundle-dev.js" : "./build/bundle.js",
bundle: true,
platform: "browser",
loader: { ".ts": "ts" },
sourcemap: isDev ? "inline" : false,
banner: {
js: `
/**
* Live Feedback script.
* @version ${packageJson.version}
* @description ${packageJson.description}
* @date ${new Date().toISOString()}
* @see https://github.com/JulianKominovic/live-feedback
* @see https://jkominovic.dev/live-feedback
**/
`,
},
jsx: "automatic",
});
if (isDev) {
await ctx.watch();
await ctx.serve({ port: 5000, servedir: "./build" });
} else {
await ctx.cancel();
await ctx
.rebuild()
.catch(console.error)
.finally(() => {
console.log("Build finished");
process.exit(0);
});
}
}
watch();