forked from shufo/prettier-plugin-blade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.ts
51 lines (46 loc) · 1.32 KB
/
esbuild.ts
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
#!/usr/bin/env node
const esbuild = require("esbuild");
// Automatically exclude all node_modules from the bundled version
const { nodeExternalsPlugin } = require("esbuild-node-externals");
if (process.env.NODE_ENV === "production") {
esbuild
.build({
entryPoints: ["./src/index.ts"],
outfile: "dist/index.js",
bundle: true,
minify: true,
platform: "node",
sourcemap: true,
target: "node14",
external: ["./src/worker"],
plugins: [nodeExternalsPlugin()],
})
.then(() => {
console.log("===========================================");
console.log(`${new Date().toLocaleString()}: build succeeded.`);
})
.catch(() => process.exit(1));
return;
}
esbuild
.build({
entryPoints: ["./src/index.ts"],
outfile: "dist/index.js",
bundle: true,
platform: "node",
sourcemap: true,
target: "node14",
plugins: [nodeExternalsPlugin()],
external: ["./src/worker"],
watch: {
onRebuild(error, result) {
if (error) console.error("watch build failed:", error);
else console.log("watch build succeeded:", result);
},
},
})
.then(() => {
console.log("===========================================");
console.log(`${new Date().toLocaleString()}: watching...`);
})
.catch(() => process.exit(1));