diff --git a/packages/backend/scripts/regenerate-all-gifs.ts b/packages/backend/scripts/regenerate-all-gifs.ts index a6029ff..2640c6c 100644 --- a/packages/backend/scripts/regenerate-all-gifs.ts +++ b/packages/backend/scripts/regenerate-all-gifs.ts @@ -1,5 +1,4 @@ import { PrismaClient, MediaKind } from '@prisma/client'; -import { generateGifFromVideo } from '../src/utils/gifGenerator.js'; import path from 'path'; import fs from 'fs'; import { fileURLToPath } from 'url'; @@ -7,6 +6,13 @@ import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); +// Dynamic import to support both dev (src/) and production (dist/) +const gifGeneratorPath = fs.existsSync(path.join(__dirname, '../dist/utils/gifGenerator.js')) + ? '../dist/utils/gifGenerator.js' + : '../src/utils/gifGenerator.js'; + +const { generateGifFromVideo } = await import(gifGeneratorPath); + const prisma = new PrismaClient(); async function regenerateAllGifs() {