-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.mjs
More file actions
31 lines (26 loc) · 753 Bytes
/
Copy pathbuild.mjs
File metadata and controls
31 lines (26 loc) · 753 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
import { build, context } from "esbuild";
import { cpSync, mkdirSync, existsSync, rmSync } from "fs";
const watch = process.argv.includes("--watch");
if (existsSync("dist")) rmSync("dist", { recursive: true });
mkdirSync("dist");
cpSync("src/index.html", "dist/index.html");
cpSync("src/style.css", "dist/style.css");
cpSync("src/favicon.svg", "dist/favicon.svg");
const options = {
entryPoints: ["src/terminal.js"],
bundle: true,
outdir: "dist",
entryNames: "[name]",
minify: !watch,
sourcemap: watch,
format: "iife",
loader: { ".css": "css" },
};
if (watch) {
const ctx = await context(options);
await ctx.watch();
console.log("Watching for changes...");
} else {
await build(options);
console.log("Build complete.");
}