-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathesbuild.js
More file actions
54 lines (49 loc) · 1.25 KB
/
esbuild.js
File metadata and controls
54 lines (49 loc) · 1.25 KB
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
// @ts-check
const esbuild = require('esbuild');
const isProduction = process.argv.includes('--production');
const isWatch = process.argv.includes('--watch');
/** @type {esbuild.BuildOptions} */
const extensionConfig = {
entryPoints: ['src/extension.ts'],
bundle: true,
external: ['vscode'],
format: 'cjs',
platform: 'node',
target: 'node16',
outfile: 'out/extension.js',
sourcemap: !isProduction,
minify: isProduction,
logLevel: 'info',
};
/** @type {esbuild.BuildOptions} */
const webviewConfig = {
entryPoints: ['src/webview/app/index.tsx'],
bundle: true,
format: 'iife',
platform: 'browser',
target: 'es2020',
outfile: 'out/webview.js',
sourcemap: !isProduction,
minify: isProduction,
logLevel: 'info',
};
async function build() {
if (isWatch) {
const [extCtx, webCtx] = await Promise.all([
esbuild.context(extensionConfig),
esbuild.context(webviewConfig),
]);
await Promise.all([extCtx.watch(), webCtx.watch()]);
console.log('[esbuild] Watching for changes...');
} else {
await Promise.all([
esbuild.build(extensionConfig),
esbuild.build(webviewConfig),
]);
console.log('[esbuild] Build complete.');
}
}
build().catch((err) => {
console.error(err);
process.exit(1);
});