mirror of
https://github.com/jsmorabito/obsidian-commander.git
synced 2026-07-22 06:40:31 +00:00
The text toolbar feature has been moved to the standalone obsidian-text-toolbar plugin at plugins/text-toolbar. This commit removes leftover staging artifacts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
133 lines
3.1 KiB
JavaScript
133 lines
3.1 KiB
JavaScript
import esbuild from "esbuild";
|
|
import process from "process";
|
|
import builtins from "builtin-modules";
|
|
import alias from "esbuild-plugin-alias";
|
|
import { sassPlugin } from "esbuild-sass-plugin";
|
|
import { createRequire } from "module";
|
|
import { renameSync, copyFileSync, appendFileSync } from "fs";
|
|
const require = createRequire(import.meta.url);
|
|
|
|
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 (https://github.com/phibr0/obsidian-commander)
|
|
*/
|
|
`;
|
|
|
|
const prod = process.argv[2] === "production";
|
|
|
|
const buildOptions = {
|
|
banner: {
|
|
js: banner,
|
|
},
|
|
footer: {
|
|
js: "\n/* by phibr0 */",
|
|
},
|
|
entryPoints: ["src/main.ts"],
|
|
bundle: true,
|
|
external: [
|
|
"obsidian",
|
|
"electron",
|
|
"@codemirror/autocomplete",
|
|
"@codemirror/closebrackets",
|
|
"@codemirror/collab",
|
|
"@codemirror/commands",
|
|
"@codemirror/comment",
|
|
"@codemirror/fold",
|
|
"@codemirror/gutter",
|
|
"@codemirror/highlight",
|
|
"@codemirror/history",
|
|
"@codemirror/language",
|
|
"@codemirror/lint",
|
|
"@codemirror/matchbrackets",
|
|
"@codemirror/panel",
|
|
"@codemirror/rangeset",
|
|
"@codemirror/rectangular-selection",
|
|
"@codemirror/search",
|
|
"@codemirror/state",
|
|
"@codemirror/stream-parser",
|
|
"@codemirror/text",
|
|
"@codemirror/tooltip",
|
|
"@codemirror/view",
|
|
...builtins,
|
|
],
|
|
format: "cjs",
|
|
loader: {
|
|
".svg": "text",
|
|
},
|
|
target: "es2017",
|
|
logLevel: "info",
|
|
sourcemap: prod ? false : "inline",
|
|
minify: prod,
|
|
treeShaking: true,
|
|
outfile: "main.js",
|
|
jsx: "automatic",
|
|
plugins: [
|
|
alias({
|
|
react: require.resolve("preact/compat"),
|
|
"react-dom/test-utils": require.resolve("preact/test-utils"),
|
|
"react-dom": require.resolve("preact/compat"),
|
|
"react/jsx-runtime": require.resolve("preact/jsx-runtime"),
|
|
}),
|
|
sassPlugin(),
|
|
{
|
|
name: "Insert Tailwind Directives",
|
|
setup(build) {
|
|
build.onEnd(() => {
|
|
try {
|
|
appendFileSync(
|
|
"main.css",
|
|
"\n@tailwind components;\n@tailwind utilities;\n"
|
|
);
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
});
|
|
},
|
|
},
|
|
{
|
|
name: "Move output",
|
|
setup(build) {
|
|
build.onEnd(() => {
|
|
// Always copy main.css → styles.css locally so Obsidian loads current styles
|
|
try {
|
|
copyFileSync("main.css", "styles.css");
|
|
} catch (error) {
|
|
console.error("Failed to copy main.css → styles.css:", error);
|
|
}
|
|
|
|
setTimeout(
|
|
() => {
|
|
try {
|
|
copyFileSync(
|
|
"styles.css",
|
|
"../../vault/.obsidian/plugins/cmdr/styles.css"
|
|
);
|
|
copyFileSync(
|
|
"main.js",
|
|
"../../vault/.obsidian/plugins/cmdr/main.js"
|
|
);
|
|
copyFileSync(
|
|
"manifest.json",
|
|
"../../vault/.obsidian/plugins/cmdr/manifest.json"
|
|
);
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
},
|
|
prod ? 5000 : 500
|
|
);
|
|
});
|
|
},
|
|
},
|
|
],
|
|
};
|
|
|
|
if (prod) {
|
|
esbuild.build(buildOptions).catch(() => process.exit(1));
|
|
} else {
|
|
// esbuild 0.17+ removed the `watch` build option in favour of a context API
|
|
esbuild
|
|
.context(buildOptions)
|
|
.then((ctx) => ctx.watch())
|
|
.catch(() => process.exit(1));
|
|
}
|