()
| 29 | } |
| 30 | |
| 31 | async function main() { |
| 32 | const name = "extension" |
| 33 | const production = process.argv.includes("--production") |
| 34 | const watch = process.argv.includes("--watch") |
| 35 | const minify = production |
| 36 | const sourcemap = true // Always generate source maps for error handling. |
| 37 | |
| 38 | /** |
| 39 | * @type {import('esbuild').BuildOptions} |
| 40 | */ |
| 41 | const buildOptions = { |
| 42 | bundle: true, |
| 43 | minify, |
| 44 | sourcemap, |
| 45 | logLevel: "silent", |
| 46 | format: "cjs", |
| 47 | sourcesContent: false, |
| 48 | platform: "node", |
| 49 | define: { |
| 50 | "process.env.PKG_RELEASE_CHANNEL": JSON.stringify(process.env.PKG_RELEASE_CHANNEL || "stable"), |
| 51 | "process.env.POSTHOG_API_KEY": JSON.stringify(process.env.POSTHOG_API_KEY || ""), |
| 52 | }, |
| 53 | } |
| 54 | |
| 55 | const srcDir = __dirname |
| 56 | const buildDir = __dirname |
| 57 | const distDir = path.join(buildDir, "dist") |
| 58 | |
| 59 | if (fs.existsSync(distDir)) { |
| 60 | console.log(`[${name}] Cleaning dist directory: ${distDir}`) |
| 61 | await removeDirWithRetries(distDir) |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * @type {import('esbuild').Plugin[]} |
| 66 | */ |
| 67 | const plugins = [ |
| 68 | { |
| 69 | name: "copyFiles", |
| 70 | setup(build) { |
| 71 | build.onEnd(() => { |
| 72 | copyPaths( |
| 73 | [ |
| 74 | ["../README.md", "README.md"], |
| 75 | ["../CHANGELOG.md", "CHANGELOG.md"], |
| 76 | ["../LICENSE", "LICENSE"], |
| 77 | ["../.env", ".env", { optional: true }], |
| 78 | ["node_modules/vscode-material-icons/generated", "assets/vscode-material-icons"], |
| 79 | ["../webview-ui/audio", "webview-ui/audio"], |
| 80 | ["assets/marketplace", "dist/assets/marketplace"], |
| 81 | ], |
| 82 | srcDir, |
| 83 | buildDir, |
| 84 | ) |
| 85 | }) |
| 86 | }, |
| 87 | }, |
| 88 | { |
no test coverage detected