import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import AutoImport from 'unplugin-auto-import/vite';
import {
  VuetifyResolver
} from 'unplugin-vue-components/resolvers';

export default defineConfig(({ mode }) =>{
 let base='';
  if(mode==='test' || mode==='production'){
    base='/admin/web/v';
  }
  return {
   base: base,
  plugins: [vue(),
    AutoImport({
      // 自动导入 Vue 相关函数，如：ref, reactive, toRef 等
      imports: ['vue'],
    }),
    Components({
      resolvers: [VuetifyResolver()],
      include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
      dirs: ['src/components', 'src/views'],
    }),
  ],
  
  server: {
    host: true,
    open: false,
    port: 3000,
    proxy: {
      '/admin': {
        //https://dev-hepa.igandan.com/admin
        target: 'https://prod-vote.igandan.com/admin', // 
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/admin/, '')
      },
    },
  },
 }
})
