// ============================================================================= // 企微IT智能服务台 — 坐席工作台 Vite 配置 // ============================================================================= // 说明:Vite 构建工具配置,定义开发服务器、构建输出等 // ============================================================================= import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' // Vite 配置 // https://vitejs.dev/config/ export default defineConfig({ // 生产环境基础路径(部署在 /itagent/ 子路径下,与IT数据平台共享域名) base: '/itagent/', // Vue3 插件 plugins: [vue()], // 开发服务器配置 server: { // 开发服务器端口(避免和H5前端冲突) port: 5173, // 自动打开浏览器 open: true, // API 代理:将 /api 请求转发到后端,解决开发环境跨域问题 proxy: { '/api': { target: 'http://localhost:8000', changeOrigin: true, // 本地开发剥离 /api 前缀,因为后端路由不包含 /api(生产 nginx 负责剥离) rewrite: (path) => path.replace(/^\/api/, ''), }, // WebSocket 代理:将 /ws 请求转发到后端 WebSocket 服务 '/ws': { target: 'ws://localhost:8000', ws: true, }, }, }, // 构建配置 build: { // 输出目录 outDir: 'dist', // 静态资源内联阈值(小于4KB的资源会被base64内联) assetsInlineLimit: 4096, }, // 路径别名 resolve: { alias: { // 使用 @ 指向 src 目录,方便导入 '@': '/src', }, }, })