mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-08-10 23:31:21 +02:00
- Removed ambiguous aliases: phpstan, cs-check, syntax - Split lint-biome into lint-css and lint-js with correct paths - Added lint meta-recipe and fix recipe (biome --unsafe + php-cs-fixer) - Fixed FormBootstrap dead null check, CSS shorthand override bug - Updated phpstan baseline, suppressed noDescendingSpecificity/noInnerDeclarations - Applied ~74 biome auto-fixes across CSS/JS
66 lines
1.8 KiB
JavaScript
66 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 { mkdirSync, writeFileSync } from "node:fs";
|
|
import { dirname, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { rolldown } from "rolldown";
|
|
|
|
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);
|
|
});
|