broekema41_obsidian-vcf-con.../esbuild.config.mjs

51 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

import builtins from "builtin-modules";
2022-12-09 22:00:16 +00:00
import esbuild from "esbuild";
import process from "process";
2022-12-09 23:08:03 +00:00
const banner = `/*
2022-12-09 22:00:16 +00:00
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;
2022-12-09 23:08:03 +00:00
const prod = process.argv[2] === "production";
2022-12-09 22:00:16 +00:00
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();
}