-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathesbuild.config.js
46 lines (41 loc) · 1014 Bytes
/
esbuild.config.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
44
45
46
// import chokidar from "chokidar";
const chokidar = require("chokidar");
const esbuild = require("esbuild");
const rimraf = require("rimraf");
const { esbuildPluginDecorator } = require("esbuild-plugin-decorator");
const { nodeExternalsPlugin } = require("esbuild-node-externals");
const esbuildOptions = {
outdir: "dist",
bundle: false,
minify: false,
platform: "node",
format: "cjs",
sourcemap: "inline",
plugins: [
nodeExternalsPlugin(),
esbuildPluginDecorator({
compiler: "swc",
tsconfigPath: "./tsconfig.json",
}),
],
};
async function build(files_) {
return await esbuild
.build({
target: "node12",
entryPoints: files_,
...esbuildOptions,
})
.catch(() => process.exit(1));
}
rimraf.sync("dist");
// One-liner for current directory
let files = [];
chokidar
.watch("./src")
.on("all", (event, path) => {
if (event === "add") files.push(path);
})
.on("ready", () => {
build(files).then((r) => process.exit(0));
});