Only show YouTube-enabled songs, exclude others from build

Filter SONGS export to only include songs with youtubeVideoId. All song
definitions remain in the source for future use. Vite plugin removes
non-YouTube song folders from dist after build so they aren't deployed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
main
Claude 2026-04-14 23:29:35 +00:00
parent b7f13f5593
commit 84a8dfc7f9
2 changed files with 26 additions and 2 deletions

View File

@ -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)

View File

@ -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 })
}
}
},
},
],
})