-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.js
37 lines (34 loc) · 902 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
/* eslint-disable @typescript-eslint/no-var-requires */
const { readFileSync } = require('fs')
const { extname, dirname: _dirname } = require('path')
async function start(watch) {
await require('esbuild').build({
entryPoints: ['src/index.ts'],
bundle: true,
watch,
minify: process.env.NODE_ENV === 'production',
sourcemap: process.env.NODE_ENV === 'development',
mainFields: ['module', 'main'],
external: ['coc.nvim'],
platform: 'node',
target: 'node10.12',
outfile: 'build/index.js',
plugins: [],
})
}
let watch = false
if (process.argv.length > 2 && process.argv[2] === '--watch') {
console.log('watching...')
watch = {
onRebuild(error) {
if (error) {
console.error('watch build failed:', error)
} else {
console.log('watch build succeeded')
}
},
}
}
start(watch).catch((e) => {
console.error(e)
})