import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import ui from '@nuxt/ui/vite'
import tailwindcss from '@tailwindcss/vite'
import { uiOptions } from './src/app.config'

var isDev = process.env.NODE_ENV == 'development'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(), tailwindcss(), isDev ? vueDevTools() : false, ui(uiOptions)],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
  base: '/',
  publicDir: './public',
  build: {
    outDir: '../assets/public/dist',
    emptyOutDir: true,
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://localhost:3000',
        changeOrigin: true,
      },
      '/health': {
        target: 'http://localhost:3000',
        changeOrigin: true,
      },
      '/swagger': {
        target: 'http://localhost:3000',
        changeOrigin: true,
      },
      '/openapi.json': {
        target: 'http://localhost:3000',
        changeOrigin: true,
      },
    },
  },
})
