mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
73 lines
1.5 KiB
JavaScript
73 lines
1.5 KiB
JavaScript
const esbuild = require("esbuild")
|
|
|
|
const production = process.argv.includes("--production")
|
|
const watch = process.argv.includes("--watch")
|
|
|
|
/**
|
|
* @type {import('esbuild').Plugin}
|
|
*/
|
|
const esbuildProblemMatcherPlugin = {
|
|
name: "esbuild-problem-matcher",
|
|
|
|
setup(build) {
|
|
build.onStart(() => {
|
|
console.log("[watch] build started")
|
|
})
|
|
build.onEnd((result) => {
|
|
result.errors.forEach(({ text, location }) => {
|
|
console.error(`✘ [ERROR] ${text}`)
|
|
console.error(` ${location.file}:${location.line}:${location.column}:`)
|
|
})
|
|
console.log("[watch] build finished")
|
|
})
|
|
},
|
|
}
|
|
|
|
const baseConfig = {
|
|
bundle: true,
|
|
minify: production,
|
|
sourcemap: !production,
|
|
logLevel: "silent",
|
|
plugins: [
|
|
/* add to the end of plugins array */
|
|
esbuildProblemMatcherPlugin,
|
|
],
|
|
}
|
|
|
|
const extensionConfig = {
|
|
...baseConfig,
|
|
entryPoints: ["src/extension.ts"],
|
|
format: "cjs",
|
|
sourcesContent: false,
|
|
platform: "node",
|
|
outfile: "dist/extension.js",
|
|
external: ["vscode"],
|
|
}
|
|
|
|
const webviewConfig = {
|
|
...baseConfig,
|
|
target: "es2020",
|
|
format: "esm",
|
|
entryPoints: ["src/webview/main.ts"],
|
|
outfile: "dist/webview.js",
|
|
}
|
|
|
|
async function main() {
|
|
const extensionCtx = await esbuild.context(extensionConfig)
|
|
const webviewCtx = await esbuild.context(webviewConfig)
|
|
if (watch) {
|
|
await extensionCtx.watch()
|
|
await webviewCtx.watch()
|
|
} else {
|
|
await extensionCtx.rebuild()
|
|
await extensionCtx.dispose()
|
|
await webviewCtx.rebuild()
|
|
await webviewCtx.dispose()
|
|
}
|
|
}
|
|
|
|
main().catch((e) => {
|
|
console.error(e)
|
|
process.exit(1)
|
|
})
|