1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import * as esbuild from 'esbuild';
const watch = process.argv.includes('--watch');
const ctx = await esbuild.context({
entryPoints: ['src/main.js'],
bundle: true,
minify: !watch,
sourcemap: watch,
outfile: 'dist/bundle.js',
target: ['es2020'],
});
if (watch) {
await ctx.watch();
console.log('watching for changes...');
} else {
await ctx.rebuild();
await ctx.dispose();
}
|