2023-04-22 03:40:53 +00:00
|
|
|
import esbuild from "esbuild";
|
2023-04-04 20:09:45 +00:00
|
|
|
import svgPlugin from "esbuild-plugin-svg";
|
2023-04-22 03:40:53 +00:00
|
|
|
import process from "process";
|
2023-05-16 21:52:45 +00:00
|
|
|
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({
|
2023-03-31 00:30:47 +00:00
|
|
|
banner: {
|
|
|
|
|
js: banner,
|
|
|
|
|
},
|
2023-03-31 04:01:39 +00:00
|
|
|
entryPoints: ["src/main.ts"],
|
2023-03-31 00:30:47 +00:00
|
|
|
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
|
|
|
],
|
2023-03-31 00:30:47 +00:00
|
|
|
format: "cjs",
|
2024-09-08 21:50:38 +00:00
|
|
|
target: "es2020",
|
2023-03-31 00:30:47 +00:00
|
|
|
logLevel: "info",
|
|
|
|
|
sourcemap: prod ? false : "inline",
|
|
|
|
|
treeShaking: true,
|
|
|
|
|
outfile: "main.js",
|
2024-11-05 22:08:13 +00:00
|
|
|
plugins: [svgPlugin(), wasmPlugin],
|
2024-08-30 06:46:35 +00:00
|
|
|
define: {
|
|
|
|
|
global: "window",
|
2025-02-12 07:59:05 +00:00
|
|
|
"process.env.NODE_ENV": prod ? '"production"' : '"development"',
|
2024-08-30 06:46:35 +00:00
|
|
|
},
|
2025-02-12 07:59:05 +00:00
|
|
|
minify: prod,
|
2023-03-31 00:15:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (prod) {
|
2023-03-31 00:30:47 +00:00
|
|
|
await context.rebuild();
|
|
|
|
|
process.exit(0);
|
2023-03-31 00:15:32 +00:00
|
|
|
} else {
|
2023-03-31 00:30:47 +00:00
|
|
|
await context.watch();
|
2024-08-21 22:16:22 +00:00
|
|
|
}
|