import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { resolve } from 'node:path'

// El bundle se construye en ../static/dist (que está en STATICFILES_DIRS),
// con manifest para que django-vite resuelva los assets en producción.
// base '/static/dist/' → coincide con static_url_prefix='dist' de django-vite.
export default defineConfig({
  plugins: [react()],
  base: '/static/dist/',
  build: {
    manifest: true,
    outDir: resolve(__dirname, '../static/dist'),
    emptyOutDir: true,
    rollupOptions: {
      input: {
        home: resolve(__dirname, 'src/entries/home.tsx'),
        login: resolve(__dirname, 'src/entries/login.tsx'),
        register: resolve(__dirname, 'src/entries/register.tsx'),
        select_account: resolve(__dirname, 'src/entries/select_account.tsx'),
        recover: resolve(__dirname, 'src/entries/recover.tsx'),
        reset_password: resolve(__dirname, 'src/entries/reset_password.tsx'),
        my_account: resolve(__dirname, 'src/entries/my_account.tsx'),
        change_password: resolve(__dirname, 'src/entries/change_password.tsx'),
        security_token: resolve(__dirname, 'src/entries/security_token.tsx'),
        change_email: resolve(__dirname, 'src/entries/change_email.tsx'),
        character_purchase: resolve(__dirname, 'src/entries/character_purchase.tsx'),
        gold_character: resolve(__dirname, 'src/entries/gold_character.tsx'),
        transfer_character: resolve(__dirname, 'src/entries/transfer_character.tsx'),
        rename_guild: resolve(__dirname, 'src/entries/rename_guild.tsx'),
        vote_points: resolve(__dirname, 'src/entries/vote_points.tsx'),
        history_table: resolve(__dirname, 'src/entries/history_table.tsx'),
        restore_character: resolve(__dirname, 'src/entries/restore_character.tsx'),
        restore_items: resolve(__dirname, 'src/entries/restore_items.tsx'),
      },
    },
  },
})
