| 1 | const esbuild = require("esbuild"); |
| 2 | |
| 3 | const production = process.argv.includes("--production"); |
| 4 | const watch = process.argv.includes("--watch"); |
| 5 | |
| 6 | /** @type {import('esbuild').BuildOptions} */ |
| 7 | const options = { |
| 8 | entryPoints: ["src/extension.ts"], |
| 9 | bundle: true, |
| 10 | outfile: "dist/extension.js", |
| 11 | format: "cjs", |
| 12 | platform: "node", |
| 13 | target: "node18", |
| 14 | external: ["vscode"], |
| 15 | sourcemap: !production, |
| 16 | minify: production, |
| 17 | logLevel: "info" |
| 18 | }; |
| 19 | |
| 20 | async function main() { |
| 21 | if (watch) { |
| 22 | const ctx = await esbuild.context(options); |
| 23 | await ctx.watch(); |
| 24 | console.log("[esbuild] watching for changes..."); |
| 25 | } else { |
| 26 | await esbuild.build(options); |
| 27 | console.log("[esbuild] build complete"); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | main().catch((err) => { |
| 32 | console.error(err); |
| 33 | process.exit(1); |
| 34 | }); |