logancyang_obsidian-copilot/esbuild.config.mjs

55 lines
1.2 KiB
JavaScript
Raw Normal View History

import esbuild from "esbuild";
2023-04-04 20:09:45 +00:00
import svgPlugin from "esbuild-plugin-svg";
import process from "process";
import wasmPlugin from "./wasmPlugin.mjs";
2023-03-31 00:15:32 +00:00
2024-08-21 22:16:22 +00:00
const banner = `/*
2023-03-31 00:15:32 +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
*/
`;
2024-08-21 22:16:22 +00:00
const prod = process.argv[2] === "production";
2023-03-31 00:15:32 +00:00
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",
2024-08-21 22:16:22 +00:00
],
format: "cjs",
target: "es2020",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outfile: "main.js",
2024-11-05 22:08:13 +00:00
plugins: [svgPlugin(), wasmPlugin],
define: {
global: "window",
2025-02-12 07:59:05 +00:00
"process.env.NODE_ENV": prod ? '"production"' : '"development"',
},
2025-02-12 07:59:05 +00:00
minify: prod,
2023-03-31 00:15:32 +00:00
});
if (prod) {
await context.rebuild();
process.exit(0);
2023-03-31 00:15:32 +00:00
} else {
await context.watch();
2024-08-21 22:16:22 +00:00
}