-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.config.js
More file actions
46 lines (41 loc) · 1.25 KB
/
esbuild.config.js
File metadata and controls
46 lines (41 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
// @ts-check
/* eslint-disable */
/**
* esbuild configuration for bundling the extension into a single CommonJS
* file at `dist/extension.js`. This dramatically reduces VSIX size and
* activation latency vs shipping raw `out/` from `tsc`.
*
* Run modes:
* node esbuild.config.js — production bundle (minified)
* node esbuild.config.js --watch — incremental rebuild for dev
* node esbuild.config.js --dev — dev bundle (no minify, sourcemaps)
*/
const esbuild = require('esbuild');
const watch = process.argv.includes('--watch');
const dev = process.argv.includes('--dev') || watch;
/** @type {import('esbuild').BuildOptions} */
const options = {
entryPoints: ['src/extension.ts'],
outfile: 'dist/extension.js',
bundle: true,
platform: 'node',
target: 'node20',
format: 'cjs',
sourcemap: dev ? 'inline' : false,
minify: !dev,
external: ['vscode'],
logLevel: 'info',
loader: { '.ts': 'ts' },
};
(async () => {
if (watch) {
const ctx = await esbuild.context(options);
await ctx.watch();
console.log('[esbuild] watching for changes…');
} else {
await esbuild.build(options);
}
})().catch((err) => {
console.error(err);
process.exit(1);
});