import { fileURLToPath, URL } from 'node:url' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import AutoImport from 'unplugin-auto-import/vite' import Components from 'unplugin-vue-components/vite' import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' // https://vitejs.dev/config/ export default defineConfig({ server: { cors: true, proxy: { // 代理所有 /api 的请求,该求情将被代理到 target 中 '/api': { // 代理请求之后的请求地址(你的真实接口地址) target: 'https://cimweb.zjw.sh.cegn.cn:2007/data-business-prod/', //target: 'http://localhost:9250/', secure: false, ws: true, // 跨域 changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ''), }, '/addressapi': { // 代理请求之后的请求地址(你的真实接口地址) target: 'https://cimweb.zjw.sh.cegn.cn:2008/', //target: 'http://localhost:9250/', secure: false, ws: true, // 跨域 changeOrigin: true, rewrite: (path) => path.replace(/^\/addressapi/, ''), }, '/netapi': { // 代理请求之后的请求地址(你的真实接口地址) target: 'http://172.16.8.44:9250/low-altitude/', //target: 'http://localhost:9250/', secure: false, ws: true, // 跨域 changeOrigin: true, rewrite: (path) => path.replace(/^\/netapi/, ''), }, '/zwapi': { // 代理请求之后的请求地址(你的真实接口地址) target: 'http://10.90.9.143:9252/', //target: 'http://localhost:9250/', secure: false, ws: true, // 跨域 changeOrigin: true, rewrite: (path) => path.replace(/^\/zwapi/, ''), }, }, }, plugins: [ vue(), AutoImport({ resolvers: [ElementPlusResolver()], }), Components({ resolvers: [ElementPlusResolver()], }), ], build: { outDir: 'low_altitude_web', }, resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), }, }, esbuild: { drop: ['console'], }, css: { preprocessorOptions: { scss: { api: 'modern-compiler', // or 'modern' }, }, }, base: '/low_altitude/', })