mirror of
https://github.com/jsmorabito/obsidian-text-formatting-toolbar.git
synced 2026-07-22 07:48:21 +00:00
- Add MIT LICENSE file - Add README with description, installation, usage, and permissions docs - Add GitHub Actions release workflow with artifact attestations - Replace builtin-modules with Node's native builtinModules Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
53 lines
1.1 KiB
JavaScript
53 lines
1.1 KiB
JavaScript
import esbuild from "esbuild";
|
|
import process from "process";
|
|
import { builtinModules } from "module";
|
|
import { sassPlugin } from "esbuild-sass-plugin";
|
|
import { copyFileSync } from "fs";
|
|
|
|
const prod = process.argv[2] === "production";
|
|
|
|
const buildOptions = {
|
|
entryPoints: ["src/main.ts"],
|
|
bundle: true,
|
|
external: [
|
|
"obsidian",
|
|
"electron",
|
|
"@codemirror/autocomplete",
|
|
"@codemirror/commands",
|
|
"@codemirror/language",
|
|
"@codemirror/state",
|
|
"@codemirror/view",
|
|
...builtinModules,
|
|
],
|
|
format: "cjs",
|
|
target: "es2017",
|
|
logLevel: "info",
|
|
sourcemap: prod ? false : "inline",
|
|
minify: prod,
|
|
treeShaking: true,
|
|
outfile: "main.js",
|
|
plugins: [
|
|
sassPlugin(),
|
|
{
|
|
name: "copy-css",
|
|
setup(build) {
|
|
build.onEnd(() => {
|
|
try {
|
|
copyFileSync("main.css", "styles.css");
|
|
} catch (e) {
|
|
console.error("Failed to copy main.css → styles.css:", e);
|
|
}
|
|
});
|
|
},
|
|
},
|
|
],
|
|
};
|
|
|
|
if (prod) {
|
|
esbuild.build(buildOptions).catch(() => process.exit(1));
|
|
} else {
|
|
esbuild
|
|
.context(buildOptions)
|
|
.then((ctx) => ctx.watch())
|
|
.catch(() => process.exit(1));
|
|
}
|