diff --git a/src/features/song-select/song-data.ts b/src/features/song-select/song-data.ts index 7ec4e58..4ba223d 100644 --- a/src/features/song-select/song-data.ts +++ b/src/features/song-select/song-data.ts @@ -1,6 +1,6 @@ import type { Song } from './types' -export const SONGS: Song[] = [ +const ALL_SONGS: Song[] = [ { id: 'get-lucky', title: 'Get Lucky', @@ -374,3 +374,6 @@ export const SONGS: Song[] = [ bannerUrl: '/songs/trap/bn.png', }, ] + +/** Only songs with YouTube audio are shown in the UI. */ +export const SONGS: Song[] = ALL_SONGS.filter((s) => s.youtubeVideoId) diff --git a/vite.config.ts b/vite.config.ts index 8b0f57b..4200668 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,7 +1,28 @@ +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()], + 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 }) + } + } + }, + }, + ], })