-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.mjs
More file actions
55 lines (48 loc) · 1.37 KB
/
esbuild.mjs
File metadata and controls
55 lines (48 loc) · 1.37 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
55
import * as esbuild from 'esbuild';
const isWatch = process.argv.includes('--watch');
/** @type {import('esbuild').BuildOptions} */
const extensionBuildOptions = {
bundle: true,
entryPoints: [ './src/extension.ts' ],
// Keep runtime dependencies like `recheck` bundled.
// The VSIX build uses `vsce --no-dependencies`, so marking them external
// leaves Node `require(...)` calls unresolved after installation.
external: [ 'vscode' ],
format: 'cjs',
minify: !isWatch,
outdir: 'dist',
platform: 'node',
sourcemap: isWatch,
target: 'node22',
};
/** @type {import('esbuild').BuildOptions} */
const webviewBuildOptions = {
bundle: true,
entryPoints: [ './src/webviews/shellCommandsPanelWebview.ts' ],
format: 'iife',
minify: !isWatch,
outdir: 'dist/webviews',
platform: 'browser',
sourcemap: isWatch,
target: 'es2023',
};
if (isWatch) {
const [ extensionContext, webviewContext ] = await Promise.all([
esbuild.context(extensionBuildOptions),
esbuild.context(webviewBuildOptions),
]);
await Promise.all([
extensionContext.watch(),
webviewContext.watch(),
]);
// eslint-disable-next-line no-console
console.log('Watching for changes...');
}
else {
await Promise.all([
esbuild.build(extensionBuildOptions),
esbuild.build(webviewBuildOptions),
]);
// eslint-disable-next-line no-console
console.log('Build complete.');
}