#!/usr/bin/env node /** * Build icons.svg — one inline SVG sprite combined from the Font Awesome Pro kit's * pre-built per-style sprites under node_modules/@awesome.me/kit-/icons/sprites/. * * Symbol ids are namespaced `dw-` (e.g. dw-house). Consumed via the dw_icon() * helper (inc/template.php) or directly: . * * Run: npm run icons (also chained into `npm run build`). * The kit is the curated icon set, so the sprite is exactly the icons we use (~40, ~40 KB) * — replacing the 689 KB Font Awesome webfont. */ import { readFileSync, writeFileSync, readdirSync } from 'node:fs'; import { resolve } from 'node:path'; const scope = 'node_modules/@awesome.me'; let kit; try { kit = readdirSync(scope).find((d) => d.startsWith('kit-')); } catch { /* scope missing */ } if (!kit) { console.error('build-icons: no @awesome.me/kit-* installed — skipping (run `npm install` your FA kit first)'); process.exit(0); } const spritesDir = resolve(scope, kit, 'icons/sprites'); const symbols = []; const seen = new Set(); for (const file of readdirSync(spritesDir).filter((f) => f.endsWith('.svg'))) { const svg = readFileSync(resolve(spritesDir, file), 'utf8'); for (const m of svg.matchAll(//g)) { const name = m[1]; if (seen.has(name)) continue; // first style wins on a name clash seen.add(name); symbols.push(``); } } symbols.sort(); const sprite = '\n'; writeFileSync('icons.svg', sprite); console.log(`build-icons: wrote icons.svg — ${symbols.length} icons from ${kit}`);