jacobtread_obsidian-timekeep/scripts/build.js
2026-03-28 15:29:31 +13:00

37 lines
931 B
JavaScript

import fs from "fs/promises";
import path from "path";
import { fileURLToPath } from "url";
import { build } from "vite";
async function buildPlugin() {
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const rootPath = path.resolve(__dirname, "../");
const manifestPath = path.join(rootPath, "manifest.json");
const outputPath = path.join(rootPath, "dist");
await ensureDir(outputPath);
await build({
configFile: path.resolve(rootPath, "vite.config.js"),
});
const destManifest = path.join(outputPath, "manifest.json");
try {
await fs.copyFile(manifestPath, destManifest);
console.info(`Copied manifest.json`);
} catch (e) {
console.error(`Failed to copy manifest.json:`, e.message);
}
}
async function ensureDir(dir) {
try {
await fs.mkdir(dir, { recursive: true });
} catch {}
}
buildPlugin().catch((err) => {
console.error(err);
process.exit(1);
});