-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.js
39 lines (30 loc) · 1.07 KB
/
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
import esbuild from 'esbuild'
// Basic options
const options = {
// Entry points and the path to the final bundle
entryPoints: ['src/index.ts'],
outdir: 'dist',
// Whether to bundle together, minify and add a source map
bundle: true,
minify: true,
sourcemap: true,
// A target environment (esbuild doesn’t support this option specified in tsconfig.json)
target: 'es6',
// Log level is specified in order to print basic information even when launched as an npm script from package.json
logLevel: 'info'
}
// Different types of builds
const configs = {
// The default one. Builds right away
'build': () => esbuild.build(options),
// The watching one. Sets the context and starts the watching process
'watch': () => esbuild.context(options).then(r => r.watch())
}
/*
Run the config. A command of the type `node esbuild.js watch` should be used. The third element of the command will be treated as a config name
*/
await configs[process.argv[2]]()
.catch(e => {
console.error(e)
process.exit(1)
})