Files
2026Technology-Competition/scripts/build.mjs
T
范智鹏 805737fcfc feat: 设置面板 + Provider 扩展 + 构建脚本
- 设置面板:三步引导 / AI 配置 / API Key / 规则管理 / 连接测试
- Provider 重构:统一 OpenAICompatibleProvider 基类,新增 Gemini/Claude/混元/智谱等
- 审查面板 Webview:三 Tab、统计卡片、问题列表、postMessage 通信
- esbuild 构建脚本 + 生产打包 + PMD 下载
- 保存文件自动静态分析(500ms debounce)
2026-07-16 22:20:30 +08:00

58 lines
1.4 KiB
JavaScript

import * as esbuild from 'esbuild';
import { copyFileSync, mkdirSync, existsSync, cpSync } from 'fs';
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const rootDir = resolve(__dirname, '..');
const outDir = resolve(rootDir, 'out');
if (!existsSync(outDir)) {
mkdirSync(outDir, { recursive: true });
}
await esbuild.build({
entryPoints: [resolve(rootDir, 'src', 'extension.ts')],
bundle: true,
outfile: resolve(outDir, 'extension.js'),
external: [
'vscode',
'eslint',
'stylelint',
'child_process',
'fs',
'path',
'url',
'os',
],
format: 'cjs',
platform: 'node',
target: 'node22',
minify: true,
sourcemap: false,
treeShaking: true,
});
const jarsSrc = resolve(rootDir, 'jars');
const jarsDest = resolve(outDir, 'jars');
if (existsSync(jarsSrc)) {
cpSync(jarsSrc, jarsDest, { recursive: true, force: true });
}
/* copy webview JS files */
const viewsSrc = resolve(rootDir, 'src', 'views');
const viewsDest = resolve(outDir, 'views');
if (existsSync(viewsSrc)) {
const files = ['setupView.js'];
for (const f of files) {
const src = resolve(viewsSrc, f);
const dest = resolve(viewsDest, f);
if (existsSync(src)) {
mkdirSync(dirname(dest), { recursive: true });
copyFileSync(src, dest);
}
}
}
console.log('Build complete.');