-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathesbuild.js
More file actions
76 lines (68 loc) · 2.06 KB
/
Copy pathesbuild.js
File metadata and controls
76 lines (68 loc) · 2.06 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
70
71
72
73
74
75
76
const esbuild = require('esbuild');
const fs = require('fs');
const path = require('path');
const isWatch = process.argv.includes('--watch');
// Ensure dist dir exists
if (!fs.existsSync('dist')) fs.mkdirSync('dist');
// Concatenate webview CSS files to dist
const stylesContent = fs.readFileSync(path.join('src', 'ui', 'webview', 'styles.css'), 'utf8');
const aiBarContent = fs.readFileSync(path.join('src', 'ui', 'webview', 'ai-bar.css'), 'utf8');
fs.writeFileSync(
path.join('dist', 'webview.css'),
stylesContent + '\n\n' + aiBarContent
);
fs.copyFileSync(
path.join('src', 'ui', 'webview', 'ai-bar.css'),
path.join('dist', 'ai-bar.css')
);
const baseConfig = {
bundle: true,
minify: !isWatch,
sourcemap: isWatch,
external: ['vscode'],
logLevel: 'info',
platform: 'node',
};
async function build() {
// Extension host bundle
const extensionCtx = await esbuild.context({
...baseConfig,
entryPoints: ['src/extension.ts'],
outfile: 'dist/extension.js',
format: 'cjs',
});
// Webview bundle (runs in browser context)
const webviewCtx = await esbuild.context({
...baseConfig,
entryPoints: ['src/ui/webview/main.ts'],
outfile: 'dist/webview.js',
format: 'iife',
platform: 'browser',
external: [],
});
// Marked markdown parser — bundled as a standalone IIFE for the chat webview.
// The chat panel reads dist/marked.js and inlines it into the webview HTML.
const markedCtx = await esbuild.context({
...baseConfig,
entryPoints: ['src/ai/markedBundle.ts'],
outfile: 'dist/marked.js',
format: 'iife',
platform: 'browser',
external: [],
});
if (isWatch) {
await extensionCtx.watch();
await webviewCtx.watch();
await markedCtx.watch();
console.log('Watching for changes...');
} else {
await extensionCtx.rebuild();
await webviewCtx.rebuild();
await markedCtx.rebuild();
await extensionCtx.dispose();
await webviewCtx.dispose();
await markedCtx.dispose();
console.log('Build complete.');
}
}
build().catch(e => { console.error(e); process.exit(1); });