import {fileURLToPath, URL} from 'node:url' import {defineConfig} from 'vite' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' import vueDevTools from 'vite-plugin-vue-devtools' import svgicon from 'vite-plugin-svgicon' import * as path from 'path' // https://vite.dev/config/ export default defineConfig({ define: { 'process.env': { 'BASE_API': '/base_api' }, }, // 配置前端服务地址和端口 server: { host: '0.0.0.0', port: 80, // 设置反向代理,跨域 proxy: { '/dify_api': { target: 'http://10.8.11.96/v1', changeOrigin: true, rewrite: path => path.replace(/^\/dify_api/, '') }, '/zhxx_api': { // 后台地址 target: 'http://10.8.4.135:8085/tba-zhxx/', changeOrigin: true, rewrite: path => path.replace(/^\/zhxx_api/, '') }, '/gx_api': { // 共享平台 target: 'http://10.8.4.136:8881/api/', changeOrigin: true, rewrite: path => path.replace(/^\/gx_api/, '') }, '/szybh_api': { // 共享平台 target: 'http://10.8.4.135:8083/', changeOrigin: true, rewrite: path => path.replace(/^\/szybh_api/, '') }, '/nmc_api': { // 共享平台 target: 'http://www.nmc.cn/', changeOrigin: true, rewrite: path => path.replace(/^\/nmc_api/, '') }, '/video_api': { // 地听视频 target: 'http://10.8.4.147:8090/', changeOrigin: true, rewrite: path => path.replace(/^\/video_api/, '') }, '/videourl_api': { // 地听视频 target: 'http://10.8.4.147:8800/', changeOrigin: true, rewrite: path => path.replace(/^\/videourl_api/, '') }, '/tsq_api': { // 南水太师桥 target: 'http://10.8.251.166:8001/', changeOrigin: true, rewrite: path => path.replace(/^\/tsq_api/, '') }, } }, plugins: [ vue(), vueJsx(), vueDevTools(), svgicon({ include: ['**/assets/svg/*.svg'], svgFilePath: path.join(__dirname, 'src/assets/svg'), }), ], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } }, css: { preprocessorOptions: { scss: { api: "modern-compiler", // or 'modern' // 自动导入定制化样式文件进行样式覆盖 // additionalData: ` // @use "@/assets/styles/element/index.scss"; // `, } } }, })