-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.config.js
63 lines (53 loc) · 1.54 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const esbuild = require('esbuild');
const copyStaticFiles = require('esbuild-copy-static-files');
const isWatchMode = process.argv.includes('--watch');
const watchNotifyPlugin = {
name: 'watch-notify',
setup(build) {
build.onEnd(result => {
if (result.warnings.length > 0) {
result.warnings.forEach(warning => console.warn(warning.text));
}
if (result.errors.length > 0) {
result.errors.forEach(error => console.error(error.text));
console.error('Build failed!');
return;
}
console.log('Build finished!');
});
},
};
async function build() {
const context = await esbuild.context({
entryPoints: ['./src/extension.js'],
bundle: true,
outfile: 'dist/extension.js',
external: ['vscode', 'antlr4'],
format: 'cjs',
platform: 'node',
plugins: [
copyStaticFiles({
src: 'src/view',
dest: 'dist/view',
}),
copyStaticFiles({
src: 'src/templates',
dest: 'dist/templates',
}),
watchNotifyPlugin,
],
});
console.log('Building extension...');
await context.rebuild();
if (isWatchMode) {
console.log('Watching for changes...');
await context.watch();
} else {
await context.dispose();
console.log('Done!');
}
}
build().catch((e) => {
console.error(e);
process.exit(1);
});