import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import mkcert from 'vite-plugin-mkcert'

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
  base: mode === 'prod' ? 'https://webapp-pub.ezijing.com/website/prod/login/' : '/',
  plugins: [mkcert(), vue(), AutoImport({ imports: ['vue', 'vue-router'] })],
  server: {
    open: true,
    host: 'dev.ezijing.com',
    proxy: {
      '/api': 'https://login.ezijing.com',
    },
  },
  build: {
    outDir: 'client-dist',
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
}))
