-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathesbuild.config.js
44 lines (41 loc) · 1.21 KB
/
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
41
42
43
44
const esbuild = require('esbuild')
const { red, cyan, green, dim } = require('kolorist')
// // Automatically exclude all node_modules from the bundled version
const { nodeExternalsPlugin } = require('esbuild-node-externals')
function logChange(metafile) {
console.log('Detected change in files: ', green(Object.keys(metafile.inputs).join(', ')))
console.log('Generated output: ', green(Object.keys(metafile.outputs).join(', ')))
console.log('')
}
esbuild
.build({
entryPoints: ['./src/index.ts'],
outfile: 'dist/index.js',
bundle: true,
minify: false,
metafile: true,
watch: {
onRebuild(error, result) {
if (error) {
console.error('There was an error rebuilding changes.', error)
console.log(dim(error.stack))
} else {
logChange(result.metafile)
if (result.errors.length) {
console.log(red('Erros: '), result.errors)
}
if (result.errors.warnings) {
console.log(cyan('Warnings: '), result.warnings)
}
}
}
},
platform: 'node',
target: 'node14',
plugins: [
nodeExternalsPlugin({
dependencies: false
})
]
})
.catch(() => process.exit(1))