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 }); } console.log('Build complete.');