-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathesbuild.config.js
40 lines (36 loc) · 914 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
/* eslint-disable @typescript-eslint/no-var-requires */
const esbuild = require('esbuild')
const yargs = require('yargs')
const { hideBin } = require('yargs/helpers')
const argv = yargs(hideBin(process.argv)).argv
const watch = async () => {
const context = await esbuild.context({
entryPoints: ['src/index.tsx'],
platform: 'node',
bundle: true,
outfile: 'lib/index.js',
color: true,
minify: argv.minify ?? false,
plugins: [
{
name: 'logger',
setup: (build) => {
build.onEnd((result) => {
if (result.errors.length) {
console.error('❌ Build failed:\n', ...result.errors)
} else {
console.log('✅ Build succeeded')
}
})
},
},
],
})
if (argv.watch) {
await context.watch()
} else {
await context.rebuild()
context.dispose()
}
}
watch()