mirror of
https://github.com/broekema41/obsidian-vcf-contacts.git
synced 2026-07-22 05:42:58 +00:00
- 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
50 lines
1.1 KiB
JavaScript
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();
|
|
}
|