import obPlugin from "./scripts/ob.esbuild.mjs"; import { build } from "esbuild"; import { join, resolve } from "path"; const banner = `/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source visit the plugins github repository */ `; const isProd = process.env.BUILD === "production"; try { await build({ entryPoints: ["src/chsp-main.ts"], bundle: true, watch: !isProd, platform: "browser", external: [ "obsidian", "@codemirror/state", "@codemirror/view", "path", "fs/promises", "@electron/remote", ], format: "cjs", mainFields: ["browser", "module", "main"], banner: { js: banner }, sourcemap: isProd ? false : "inline", minify: isProd, define: { "process.env.NODE_ENV": JSON.stringify(process.env.BUILD), }, outfile: "build/main.js", plugins: [ obPlugin(), { name: "cm6-src", setup: (build) => build.onResolve({ filter: /^cm6-view-src/ }, (args) => { return { path: resolve(join("node_modules", args.path + ".ts")), }; }), }, ], }); } catch (err) { console.error(err); process.exit(1); }