import { defineConfig } from 'vite' import uni from '@dcloudio/vite-plugin-uni' import path from 'path' const define = {} if (!["mp-weixin", "h5", "web"].includes(process.env.UNI_PLATFORM)) { define['global'] = null define['wx'] = 'uni' } export default defineConfig({ resolve: { alias: { '@': path.resolve(__dirname, '.') } }, plugins: [uni()], define, // base: process.env.NODE_ENV === 'production' ? './' : '/', // transpileDependencies: ['@dcloudio/uni-ui'], server: { port: 8088, proxy: { '/api': { target: 'https://dev3.k12100.net/teaching/api/', // 目标后端服务器地址 // target: 'https://www.k12100.com/teaching/api/', changeOrigin: true, // 是否改变源 // rewrite: (path) => path.replace(/^\/api/, '/') // 重写路径 rewrite: (path) => path.endsWith('.js') ? '' : path.replace(/^\/api/, '/') } } } })