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