-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.config.js
More file actions
49 lines (42 loc) · 1021 Bytes
/
esbuild.config.js
File metadata and controls
49 lines (42 loc) · 1021 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
import { exec } from "child_process";
import * as esbuild from "esbuild";
const isServe = process.argv.includes("--serve");
function packZip() {
exec("node ./pack-zip.js", (err, stdout, stderr) => {
if (err) {
console.error("Error packing zip:", err);
return;
}
console.log(stdout.trim());
});
}
const zipPlugin = {
name: "zip-plugin",
setup(build) {
build.onEnd(() => {
packZip();
});
},
};
let buildConfig = {
entryPoints: ["src/main.ts"],
bundle: true,
minify: !isServe,
logLevel: "info",
color: true,
outdir: "dist",
plugins: [zipPlugin],
resolveExtensions: ['.ts', '.d.ts']
};
(async function () {
if (isServe) {
console.log("Starting development server...");
const ctx = await esbuild.context(buildConfig);
await ctx.watch();
await ctx.serve({ servedir: ".", port: 3080 });
} else {
console.log("Building for production...");
await esbuild.build(buildConfig);
console.log("Production build complete.");
}
})();