Initial commit... a site is born (again? finally?)

This commit is contained in:
2026-01-30 19:58:22 +00:00
commit 1519dfa460
62 changed files with 5674 additions and 0 deletions

48
build.mjs Normal file
View File

@@ -0,0 +1,48 @@
#!/usr/bin/env node
/**
* Build script: copies entire site/ to dist/, then inlines critical CSS in dist/index.html.
* Uses Critters (no headless browser) so the build runs in any environment.
* Dockerfile copies only dist/ — single source of truth for the built site.
*/
import Critters from "critters";
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ROOT = path.join(__dirname);
const SITE = path.join(ROOT, "site");
const DIST = path.join(ROOT, "dist");
async function main() {
// Copy entire site structure to dist
if (fs.existsSync(DIST)) {
fs.rmSync(DIST, { recursive: true });
}
fs.cpSync(SITE, DIST, { recursive: true });
console.log("✓ Copied site/ → dist/");
// Inline critical CSS in dist/index.html (Critters reads/writes relative to path)
const indexPath = path.join(DIST, "index.html");
let html = fs.readFileSync(indexPath, "utf8");
const critters = new Critters({
path: DIST,
preload: "swap",
noscriptFallback: true,
pruneSource: false,
logLevel: "warn",
});
html = await critters.process(html);
fs.writeFileSync(indexPath, html, "utf8");
console.log("✓ Critical CSS inlined → dist/index.html");
console.log("Build complete. Output: dist/");
}
main().catch((err) => {
console.error(err);
process.exit(1);
});