Files
yunzerwebsiteallinone/uniapp/vite.config.js
T
2026-07-15 22:38:33 +08:00

30 lines
732 B
JavaScript

import { defineConfig, loadEnv } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const apiTarget = (env.VITE_API_BASE_URL || 'http://localhost:9000').replace(/\/$/, '')
return {
plugins: [uni()],
server: {
proxy: {
// 勿用 /api:会与 uniapp/api/ 源码目录冲突,导致 request.js 等模块 404
'/proxy-api': {
target: apiTarget,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/proxy-api/, '')
}
}
},
css: {
preprocessorOptions: {
scss: {
// 关闭废弃 API 警告
silenceDeprecations: ['legacy-js-api', 'color-functions', 'import']
}
}
}
}
})