sbuffkin_hexmaker/esbuild.config.mjs
nyxsys 965dcd2d08 feat: bundle built-in icons into main.js as data URLs
Icons are now embedded at build time via esbuild dataurl loader, so
they work for all install methods without requiring a separate icons/
folder in the release assets.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 16:17:52 -04:00

42 lines
920 B
JavaScript

import esbuild from "esbuild";
import process from "process";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const pkg = require("./package.json");
const fs = require("fs");
const production = process.argv[2] === "production";
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
*/
`;
const prod = production;
const outDir = ".";
const outFile = "main.js";
const context = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ["main.ts"],
bundle: true,
external: ["obsidian"],
format: "cjs",
target: "es2018",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outfile: `${outDir}/${outFile}`,
loader: { ".md": "text", ".png": "dataurl" },
});
if (prod) {
await context.rebuild();
process.exit(0);
} else {
await context.watch();
}