import tailwindcss from '@tailwindcss/vite'
import { TanStackRouterVite } from '@tanstack/router-plugin/vite'
import react from '@vitejs/plugin-react'
import path from 'node:path'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    TanStackRouterVite({
      target: 'react',
      autoCodeSplitting: true,
      routesDirectory: './src/routes',
      generatedRouteTree: './node_modules/.cache/tanstack-router/routeTree.gen.ts',
    }),
    react(),
    tailwindcss(),
  ],
  resolve: {
    alias: {
      '~': path.resolve(__dirname, './src'),
      '~generated': path.resolve(__dirname, './node_modules/.cache'),
    },
  },
  server: {
    port: 3000,
  },
  build: {
    outDir: 'node_modules/.cache/dist',
    emptyOutDir: true,
  },
  cacheDir: 'node_modules/.cache/vite',
})
