mirror of
https://github.com/mntno/obsidian-come-through.git
synced 2026-07-22 05:47:56 +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 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" : ".";
|
|
|
|
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",
|
|
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();
|
|
fs.copyFileSync("manifest.json", "dist/manifest.json");
|
|
process.exit(0);
|
|
} else {
|
|
await context.watch();
|
|
}
|