import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { paraglideVitePlugin } from '@inlang/paraglide-js'
import path from 'node:path'

export default defineConfig({
  plugins: [
    // Compile messages/*.json → src/paraglide so `m`/`mKey` resolve, with HMR on
    // message edits. Must run first.
    paraglideVitePlugin({ project: './project.inlang', outdir: './src/paraglide' }),
    tanstackStart({
      router: {
        routesDirectory: path.resolve(import.meta.dirname, 'src/pages'),
        generatedRouteTree: path.resolve(import.meta.dirname, 'src/routeTree.gen.ts'),
        routeFileIgnorePrefix: '-',
        quoteStyle: 'single',
      },
    }),
    react(),
  ],
  server: {
    port: 7104,
    host: '0.0.0.0',
    proxy: {
      '/api': 'http://localhost:4003',
    },
  },
  resolve: {
    alias: {
      '@': path.resolve(import.meta.dirname, 'src'),
    },
  },
})
