swarnam-obsidian/esbuild.config.mjs

48 lines
953 B
JavaScript
Raw Permalink Normal View History

import esbuild from "esbuild";
import process from "process";
2023-01-25 18:49:50 +00:00
import builtins from "builtin-modules";
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
*/
`;
2023-01-25 18:49:50 +00:00
const prod = (process.argv[2] === "production");
2023-01-25 18:49:50 +00:00
const context = await esbuild.context({
banner: {
js: banner,
},
2023-01-25 18:49:50 +00:00
entryPoints: ["main.ts"],
bundle: true,
external: [
2023-01-25 18:49:50 +00:00
"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],
2023-01-25 18:49:50 +00:00
format: "cjs",
target: "es2018",
logLevel: "info",
2023-01-25 18:49:50 +00:00
sourcemap: prod ? false : "inline",
treeShaking: true,
2023-01-25 18:49:50 +00:00
outfile: "main.js",
});
if (prod) {
await context.rebuild();
process.exit(0);
} else {
await context.watch();
}