mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
- package.json with biome, rolldown, lightningcss devDependencies
- biome.json: add CSS formatter support
- scripts/build-css.mjs: lightningcss resolves @import chain, bundles/minifies CSS
- scripts/build-js.mjs: rolldown per-entry JS bundling (no code splitting)
- scripts/build.mjs: orchestrator for both CSS + JS
- scripts/check-build.mjs: staleness checker for CI/deploy guard
- justfile: add build, build-css, build-js, build-install, build-check recipes
- justfile: deploy recipe now runs build before deploy-code
- head.php + form-page.php: use dist/base.min.css instead of style.css
- All controllers + FormBootstrap: reference dist/*.min.{css,js}
- admin footer: load admin.min.js for all admin pages
- repertoire: use public.min.js instead of individual app JS files
- Fix stray '}' syntax error in admin.css line 305
- .gitignore: add app/public/assets/dist/
65 lines
1.8 KiB
JavaScript
65 lines
1.8 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Build JS bundles: one self-contained file per entry point.
|
|
*
|
|
* Each bundle includes all its dependencies inline (no code splitting).
|
|
* Output: app/public/assets/dist/{admin,public,form,partage}.min.js
|
|
*/
|
|
|
|
import { rolldown } from "rolldown";
|
|
import { resolve, dirname } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { writeFileSync, mkdirSync } from "node:fs";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const root = resolve(__dirname, "..");
|
|
const jsDir = resolve(root, "app/public/assets/js/app");
|
|
const distDir = resolve(root, "app/public/assets/dist");
|
|
|
|
mkdirSync(distDir, { recursive: true });
|
|
|
|
const entries = {
|
|
admin: resolve(jsDir, "admin-entry.js"),
|
|
public: resolve(jsDir, "public-entry.js"),
|
|
form: resolve(jsDir, "form-entry.js"),
|
|
partage: resolve(jsDir, "partage-entry.js"),
|
|
};
|
|
|
|
async function buildEntry(name, input) {
|
|
const bundle = await rolldown({
|
|
input,
|
|
resolve: { extensions: [".js"] },
|
|
output: {
|
|
format: "esm",
|
|
minify: true,
|
|
},
|
|
});
|
|
|
|
const { output } = await bundle.generate();
|
|
// output is an array of OutputChunks; we want the entry chunk
|
|
const entryChunk = output.find((c) => c.isEntry);
|
|
if (!entryChunk) {
|
|
console.error(` ✗ ${name}.min.js — no entry chunk`);
|
|
return;
|
|
}
|
|
|
|
const outPath = resolve(distDir, `${name}.min.js`);
|
|
writeFileSync(outPath, entryChunk.code);
|
|
|
|
const size = Buffer.byteLength(entryChunk.code, "utf8");
|
|
console.log(` ✓ ${name}.min.js (${size.toLocaleString()} bytes)`);
|
|
}
|
|
|
|
async function main() {
|
|
console.log("📦 Building JS bundles…\n");
|
|
for (const [name, input] of Object.entries(entries)) {
|
|
await buildEntry(name, input);
|
|
}
|
|
console.log("\n✅ JS bundles done\n");
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error("❌ JS build failed:", err);
|
|
process.exit(1);
|
|
});
|