logancyang_obsidian-copilot/esbuild.config.mjs

62 lines
1.3 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";
import { nodeModulesPolyfillPlugin } from "esbuild-plugins-node-modules-polyfill";
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: "es2018",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outfile: "main.js",
plugins: [
svgPlugin(),
wasmPlugin,
nodeModulesPolyfillPlugin({
modules: {
events: true,
},
}),
],
define: {
global: "window",
},
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
}