import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import react from '@vitejs/plugin-react';
import { lingui } from '@lingui/vite-plugin';

export default defineConfig(({ mode }) => ({
  server: {
    port: 3000,
    allowedHosts: ["dev.flexxon.app", "flexxon.app"]
  },
  ssr: {
    noExternal: mode === 'production' ? true : ['facehash'],
  },
  plugins: [
    tsConfigPaths({
      projects: ['./tsconfig.json'],
    }),
    tanstackStart({
      srcDirectory: 'src/app',
    }),
    lingui(),
    react({
      babel: {
        plugins: [
          // lingui must run before react-compiler: the compiler's memoization
          // rewrites JSX in ways the macro can no longer transform
          '@lingui/babel-plugin-lingui-macro',
          'babel-plugin-react-compiler',
        ],
      },
    }),
  ]
}))
