-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.js
More file actions
69 lines (58 loc) · 1.96 KB
/
esbuild.js
File metadata and controls
69 lines (58 loc) · 1.96 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// @ts-check
'use strict';
const esbuild = require('esbuild');
const fs = require('fs');
const path = require('path');
const watch = process.argv.includes('--watch');
const minify = process.argv.includes('--minify');
/** @type {import('esbuild').BuildOptions} */
const base = {
bundle: true,
platform: 'node',
format: 'cjs',
target: 'node18',
minify,
sourcemap: !minify,
};
function copyVendorAssets() {
const vendorDir = path.join(__dirname, 'dist', 'vendor');
const codiconsDir = path.join(vendorDir, 'codicons');
fs.mkdirSync(codiconsDir, { recursive: true });
// mermaid — loaded as a WebView static asset, not bundled
fs.copyFileSync(
path.join(__dirname, 'node_modules', 'mermaid', 'dist', 'mermaid.min.js'),
path.join(vendorDir, 'mermaid.min.js')
);
// codicons — CSS + font required by WebView
const codiconSrc = path.join(__dirname, 'node_modules', '@vscode', 'codicons', 'dist');
fs.copyFileSync(path.join(codiconSrc, 'codicon.css'), path.join(codiconsDir, 'codicon.css'));
fs.copyFileSync(path.join(codiconSrc, 'codicon.ttf'), path.join(codiconsDir, 'codicon.ttf'));
}
async function main() {
copyVendorAssets();
/** @type {import('esbuild').BuildOptions} */
const clientConfig = {
...base,
entryPoints: ['client/src/extension.ts'],
outfile: 'client/out/extension.js',
external: ['vscode'],
};
/** @type {import('esbuild').BuildOptions} */
const serverConfig = {
...base,
entryPoints: ['server/src/server.ts'],
outfile: 'server/out/server.js',
};
if (watch) {
const [clientCtx, serverCtx] = await Promise.all([
esbuild.context(clientConfig),
esbuild.context(serverConfig),
]);
await Promise.all([clientCtx.watch(), serverCtx.watch()]);
console.log('[esbuild] watching…');
} else {
await Promise.all([esbuild.build(clientConfig), esbuild.build(serverConfig)]);
console.log('[esbuild] done');
}
}
main().catch(e => { console.error(e); process.exit(1); });