mirror of
https://github.com/mntno/obsidian-come-down.git
synced 2026-07-22 05:43:15 +00:00
59 lines
1.3 KiB
JavaScript
59 lines
1.3 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"));
|
|
fs.copyFileSync("styles.css", path.join(outdir, "styles.css"));
|
|
|
|
const context = 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",
|
|
// Runtime of min supported Obsidian version 1.8.0, see manifest.json
|
|
target: "es2024",
|
|
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();
|
|
}
|