Problem: Script failed in production Docker container because it tried
to import from '../src/utils/gifGenerator.js' which doesn't exist in
production (only compiled dist/ directory exists).
Error:
Cannot find module '/app/packages/backend/src/utils/gifGenerator.js'
Solution: Use dynamic import with path detection to support both
development and production environments.
Changes:
- Check if dist/utils/gifGenerator.js exists (production)
- Fall back to src/utils/gifGenerator.js (development)
- Use dynamic import with await to load the correct module
This allows the script to work in both:
- Development: npx tsx scripts/regenerate-all-gifs.ts
- Production: Docker container with REGENERATE_GIFS=true
Tested: Docker container now starts successfully and executes the
GIF regeneration script without errors.
Co-Authored-By: Auggie
Added utility scripts for GIF management:
1. regenerate-all-gifs.ts:
- Regenerates GIF previews for all existing videos
- Deletes old GIFs before creating new ones
- Provides progress feedback and summary statistics
- Useful for bulk GIF generation after deployment
2. check-gifs.ts:
- Quick diagnostic to list all GIF records in database
- Shows term names and GIF URLs
- Useful for verifying GIF generation
3. insert-gif-test.ts:
- Test script to verify GIF enum value works in database
- Creates, verifies, and cleans up test GIF record
- Includes Prisma query logging for debugging
Usage:
cd packages/backend
npx tsx scripts/regenerate-all-gifs.ts
npx tsx scripts/check-gifs.ts
npx tsx scripts/insert-gif-test.ts
Co-Authored-By: Auggie