broekema41_obsidian-vcf-con.../esbuild.config.mjs
Bjørn Stabell 06c17d246a feat: Add watch mode for development builds
- Use esbuild context API for both watch and single builds
- Run with 'node esbuild.config.mjs watch' for watch mode
- Auto-rebuild on file changes during development
- Properly dispose context after single builds
- Add minimal development documentation to README
2025-08-29 16:40:31 -07:00

50 lines
1.1 KiB
JavaScript

import builtins from "builtin-modules";
import esbuild from "esbuild";
import process from "process";
const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;
const prod = process.argv[2] === "production";
const ctx = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ["src/main.ts"],
bundle: true,
external: [
"obsidian",
"electron",
"@codemirror/autocomplete",
"@codemirror/collab",
"@codemirror/commands",
"@codemirror/language",
"@codemirror/lint",
"@codemirror/search",
"@codemirror/state",
"@codemirror/view",
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
...builtins,
],
format: "cjs",
target: "es2022",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
minify: true,
outfile: "main.js",
});
if (process.argv[2] === "watch") {
await ctx.watch();
console.log("⚡ Watch mode enabled - rebuilding on file changes...");
} else {
await ctx.rebuild();
await ctx.dispose();
}