-
Notifications
You must be signed in to change notification settings - Fork 1
/
esbuild.js
41 lines (37 loc) · 966 Bytes
/
esbuild.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
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-var-requires */
// @ts-check
const isWatch = process.argv.length > 2 && process.argv[2] === '--watch'
async function start() {
const ctx = await require('esbuild').context({
entryPoints: ['src/index.ts'],
bundle: true,
minify: process.env.NODE_ENV === 'production',
sourcemap: process.env.NODE_ENV === 'development',
mainFields: ['module', 'main'],
external: ['coc.nvim', '@shd101wyy/mume'],
platform: 'node',
target: 'node14.14',
outfile: 'lib/index.js',
plugins: [
{
name: 'my-watch-plugin',
setup(build) {
build.onEnd(() => {
console.log('built', new Date().toLocaleString())
})
},
},
],
})
if (isWatch) {
await ctx.watch()
console.log('watching...')
} else {
await ctx.rebuild()
await ctx.dispose()
}
}
start().catch((e) => {
console.error(e)
})