/** * Concatenates selected Lucide icons into one sprite: app/static/dist/icons.svg * (Chapter 05). Build-time only — never runs on the cPanel host. */ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = dirname(fileURLToPath(import.meta.url)); const ICONS_DIR = join(__dirname, '../node_modules/lucide-static/icons'); const OUT_PATH = join(__dirname, '../app/static/dist/icons.svg'); // NOTE: verify against node_modules/lucide-static/icons/ when bumping the // lucide-static version — icon names get renamed upstream (e.g. 'home' -> // 'house', 'alert-triangle' -> 'triangle-alert' as of 0.446.0; caught by // actually running this script against a real install). const ICON_NAMES = [ 'house', 'search', 'shield-alert', 'upload', 'download', 'chevron-down', 'chevron-right', 'x', 'triangle-alert', 'bot', 'sun', 'moon', 'log-out', 'loader-circle', ]; function extractInner(svg) { const match = svg.match(/]*>([\s\S]*)<\/svg>/); if (!match) throw new Error('Unexpected SVG shape'); return match[1].trim(); } const symbols = ICON_NAMES.map((name) => { const raw = readFileSync(join(ICONS_DIR, `${name}.svg`), 'utf8'); return `${extractInner(raw)}`; }); mkdirSync(dirname(OUT_PATH), { recursive: true }); writeFileSync(OUT_PATH, `\n${symbols.join('\n')}\n\n`); console.log(`Wrote ${ICON_NAMES.length} icons to ${OUT_PATH}`);