import { defineConfig } from 'astro/config'
import node from '@astrojs/node'
import react from '@astrojs/react'
import tailwindcss from '@tailwindcss/vite'

export default defineConfig({
  outDir: process.env.ASTRO_OUT_DIR ?? './dist',
  output: 'static',
  // Required for the on-demand src/pages/api/collector proxy route (export const prerender
  // = false) even though every page stays static; all other routes are unaffected.
  adapter: node({ mode: 'standalone' }),
  integrations: [react()],
  vite: {
    optimizeDeps: {
      noDiscovery: true,
      include: [
        '@overdeck/deck-ui',
        '@overdeck/deck-ui/project-colors',
        '@platform-modules/query-react',
        '@platform-modules/query-react/persist',
        '@platform-modules/ui-primitives',
        '@platform-modules/ui-primitives/QueryBoundary',
        '@platform-modules/ui-primitives/Skeleton',
        '@platform-modules/ui-primitives/Toast',
        '@tanstack/query-sync-storage-persister',
        '@tanstack/react-query',
        '@tanstack/react-query-persist-client',
        'react',
        'react-dom',
        'react-dom/client',
        'react/jsx-dev-runtime',
        'react/jsx-runtime',
      ],
    },
    plugins: [tailwindcss()],
  },
})
