-
Notifications
You must be signed in to change notification settings - Fork 2
/
esbuild.ts
39 lines (34 loc) · 858 Bytes
/
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
/**
* This is the build script for the project.
*
* It takes the source code and bundles it into a single file
* that can be imported into an inlang project.
*/
import { context } from 'esbuild'
import { pluginBuildConfig } from "@inlang/core/plugin"
const isDev = !!process.env.DEV
const options = await pluginBuildConfig({
entryPoints: ["./src/index.js"],
outfile: "./dist/index.js",
minify: !isDev,
sourcemap: true,
plugins: [
{
name: "logger",
setup: ({ onEnd }) => onEnd(() => console.info("🎉 changes processed")),
},
],
})
const ctx = await context(options)
if (isDev) {
await ctx.watch()
console.info("👀 watching for changes...")
process.on('exit', async () => {
console.info('🙈 process killed')
await ctx.dispose()
})
} else {
await ctx.rebuild()
console.info("✅ build complete")
await ctx.dispose()
}