mntno_obsidian-come-through/esbuild.config.mjs
2026-05-05 17:58:17 +07:00

62 lines
1.4 KiB
JavaScript

import builtins from "builtin-modules";
import esbuild from "esbuild";
import fs from "fs";
import path from "path";
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 outdir = prod ? "dist" : "dev-vault";
fs.copyFileSync("manifest.json", path.join(outdir, "manifest.json"));
const context = await esbuild.context({
banner: {
js: banner,
},
// When you use an object for entryPoints, the keys become the output filenames and the values are the input file paths.
entryPoints: {
main: "src/main.ts",
styles: "styles/main.css"
},
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",
// Runtime of min supported Obsidian version 1.8.2, see manifest.json
target: "es2022",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outdir: outdir,
minify: prod,
define: {
"process.env.NODE_ENV": prod ? '"production"' : '"development"',
},
});
if (prod) {
await context.rebuild();
process.exit(0);
} else {
await context.watch();
}