| 1234567891011121314151617181920212223242526 |
- import { defineConfig, loadEnv } from 'vite'
- import uni from '@dcloudio/vite-plugin-uni'
- /**
- * uni-app Vue3 H5 开发代理
- * - /dev-api → 若依后端(.env.development 的 VITE_APP_API_HOST)
- */
- export default defineConfig(({ mode }) => {
- const env = loadEnv(mode, process.cwd(), '')
- const devApiTarget = String(env.VITE_APP_API_HOST || 'http://192.168.1.6:8010').replace(/\/$/, '')
- const devApiPrefix = String(env.VITE_APP_BASE_API || '/dev-api')
- return {
- plugins: [uni()],
- server: {
- proxy: {
- [devApiPrefix]: {
- target: devApiTarget,
- changeOrigin: true,
- rewrite: (path) => path.replace(new RegExp(`^${devApiPrefix}`), '')
- }
- }
- }
- }
- })
|