import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

export default defineConfig({
  plugins: [
    vue()
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  },
  // lru-cache@11 的 ESM 入口含顶层 await；默认 es2020 目标会在预构建/最终转译阶段报错
  build: {
    target: 'es2022'
  },
  optimizeDeps: {
    esbuildOptions: {
      target: 'es2022'
    }
  },
  server: {
    host: true,
    proxy: {
      '/cloud': {
        target: 'https://xxoo365.top/cloud',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/cloud/, '')
      }
    }
  }
})
