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

import vue from '@vitejs/plugin-vue'
import vueDevTools from "vite-plugin-vue-devtools";

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  return {
    plugins: [vue(), vueDevTools()],
    server: {
      port: 8917,
      cors: true,
      proxy: {
        "/api": {
          target: "http://192.168.121.203:18080",
          changeOrigin: true,
          secure: false,
        },
      },
    },
    resolve: {
      extensions: ['.vue', '.ts',  '.js', '.json', '.tsx', '.jsx'],
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url))
      }
    },
    esbuild: {
      drop: mode === 'production' ? ['console', 'debugger'] : []
    },
    define: {
      // 启用生产环境构建下激活不匹配的详细警告
      __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false',
      __VUE_OPTIONS_API__: "true",
      __VUE_PROD_DEVTOOLS__: "true"
    }
  }
})
