-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.mjs
37 lines (33 loc) · 1 KB
/
esbuild.mjs
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
import * as esbuild from 'esbuild';
const baseConfig = {
bundle: true,
minify: process.env.NODE_ENV === 'production',
sourcemap: process.env.NODE_ENV === 'production' ? false : true
};
const extensionConfig = {
...baseConfig,
platform: 'node',
entryPoints: ['./src/extension.ts'],
outfile: './out/extension.js',
external: ['vscode']
};
const webviewConfig = {
...baseConfig,
platform: 'browser',
entryPoints: ['./src/webview/main.ts'],
outfile: './out/webview.js'
};
(async () => {
const args = process.argv.slice(2);
if (args.includes('--watch')) {
// build and watch extension and webview code
await (await esbuild.context(extensionConfig)).watch();
await (await esbuild.context(webviewConfig)).watch();
console.log('watch started');
} else {
// build extension and webview code
await esbuild.build(extensionConfig);
await esbuild.build(webviewConfig);
console.log('build complete');
}
})();