mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-08-10 23:31:21 +02:00
60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Build all frontend assets: CSS + JS.
|
|
*
|
|
* Usage:
|
|
* node scripts/build.mjs # build everything
|
|
* node scripts/build.mjs --css # CSS only
|
|
* node scripts/build.mjs --js # JS only
|
|
* node scripts/build.mjs --quiet # suppress per-file output, summary only
|
|
*
|
|
* Requires: npm install (lightningcss-cli, rolldown)
|
|
*/
|
|
|
|
import { execSync } from "node:child_process";
|
|
import { existsSync } from "node:fs";
|
|
import { dirname, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const root = resolve(__dirname, "..");
|
|
|
|
const args = process.argv.slice(2);
|
|
const onlyCss = args.includes("--css");
|
|
const onlyJs = args.includes("--js");
|
|
const quiet = args.includes("--quiet");
|
|
const buildAll = !onlyCss && !onlyJs;
|
|
|
|
function run(label, cmd) {
|
|
if (quiet) {
|
|
execSync(cmd, { cwd: root, stdio: "pipe" });
|
|
} else {
|
|
console.log(`\n📦 ${label}…`);
|
|
execSync(cmd, { cwd: root, stdio: "inherit" });
|
|
}
|
|
}
|
|
|
|
// Ensure node_modules exist
|
|
if (!existsSync(resolve(root, "node_modules"))) {
|
|
console.log("📥 Installing dependencies (npm ci)…");
|
|
execSync("npm ci", { cwd: root, stdio: "inherit" });
|
|
}
|
|
|
|
if (buildAll || onlyCss) {
|
|
run("Linting CSS + JS (biome)", "npx biome lint app/public/assets/css/ app/public/assets/js/app/ scripts/ || true");
|
|
}
|
|
|
|
if (buildAll || onlyCss) {
|
|
run("Building CSS bundles", "node scripts/build-css.mjs");
|
|
}
|
|
|
|
if (buildAll || onlyJs) {
|
|
run("Building JS bundles", "node scripts/build-js.mjs");
|
|
}
|
|
|
|
if (quiet) {
|
|
console.log("✅ CSS/JS rebuilt");
|
|
} else {
|
|
console.log("\n✅ Build complete\n");
|
|
}
|