import fs from 'fs' import path from 'path' import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import { SONGS } from './src/features/song-select/song-data' // Song folders to include in the build (only YouTube-enabled songs). // Other song folders stay in the repo but are excluded from dist. const activeSongIds = new Set(SONGS.map((s) => s.id)) // https://vite.dev/config/ export default defineConfig({ plugins: [ react(), { name: 'exclude-inactive-songs', closeBundle() { const songsDir = path.resolve(__dirname, 'dist/songs') if (!fs.existsSync(songsDir)) return for (const dir of fs.readdirSync(songsDir)) { if (!activeSongIds.has(dir)) { fs.rmSync(path.join(songsDir, dir), { recursive: true }) } } }, }, ], })