refactor: implement scalable asset manifest system for dynamic images

Created build-time script to generate TypeScript manifest from public/assets, avoiding import.meta.glob limitations. Images stay in public/ for scalability (supports hundreds), while components get type-safe auto-discovery. Manifest auto-regenerates before builds.
This commit is contained in:
plebeius
2025-11-01 19:39:22 +01:00
parent 967584294c
commit f26da13c77
6 changed files with 83 additions and 27 deletions
+25
View File
@@ -0,0 +1,25 @@
# Generated Files
This directory contains auto-generated TypeScript files. Do not edit these files manually.
## asset-manifest.ts
Auto-generated manifest of all banner and not-found images from `public/assets/`.
**To regenerate:**
```bash
yarn generate:assets
```
**Auto-regenerated:**
- Before every build (`yarn build`)
- Before dev server start (`yarn start`)
**To add new banners:**
1. Add files to `public/assets/banners/` following the pattern `banner-*.{jpg,jpeg,gif,png}`
2. Run `yarn generate:assets` (or it will auto-run on next build/start)
**To add new not-found images:**
1. Add files to `public/assets/not-found/` following the pattern `not-found-*.{jpg,jpeg,gif,png}`
2. Run `yarn generate:assets` (or it will auto-run on next build/start)
+13
View File
@@ -0,0 +1,13 @@
// Auto-generated file - do not edit manually
// Run 'node scripts/generate-asset-manifest.js' to regenerate
// This file is generated from public/assets/ directory
export const BANNERS = [
'assets/banners/banner-1.jpg',
'assets/banners/banner-2.jpg',
'assets/banners/banner-3.gif',
'assets/banners/banner-4.gif',
'assets/banners/banner-5.png',
] as const;
export const NOT_FOUND_IMAGES = ['assets/not-found/not-found-1.png'] as const;