const images = import.meta.glob("/src/assets/**/*.{jpg,png}", { eager: true }) as Record; export function findImageByPath(path: string, { fallback }: { fallback?: string } = {}): any { if (!path) return fallback ?? null; const key = Object.keys(images).find( p => p.endsWith("/" + path) || p.endsWith(path) ); if (!key) { if (fallback) return fallback; throw new Error(`Image not found: ${path}`); } return images[key].default; }