|
@@ -1,23 +1,29 @@ |
|
|
import { defineConfig } from 'vite' |
|
|
|
|
|
|
|
|
import { defineConfig, loadEnv } from 'vite' |
|
|
import uni from '@dcloudio/vite-plugin-uni' |
|
|
import uni from '@dcloudio/vite-plugin-uni' |
|
|
|
|
|
|
|
|
// https://vitejs.dev/config/ |
|
|
// https://vitejs.dev/config/ |
|
|
export default defineConfig({ |
|
|
|
|
|
transpileDependencies: ['uview-ui'], |
|
|
|
|
|
plugins: [ |
|
|
|
|
|
uni(), |
|
|
|
|
|
], |
|
|
|
|
|
server: { |
|
|
|
|
|
host: "0.0.0.0", |
|
|
|
|
|
port: '8591', |
|
|
|
|
|
open: true, // 运行是否自动打开浏览器 |
|
|
|
|
|
proxy: { |
|
|
|
|
|
// 反向代理解决跨域 |
|
|
|
|
|
"/api": { |
|
|
|
|
|
target: 'https://test.metavatar.cc/C', // 线上接口地址 |
|
|
|
|
|
changeOrigin: true, |
|
|
|
|
|
rewrite: (path) => path.replace(/^\/api/, ""), |
|
|
|
|
|
|
|
|
export default defineConfig(({ command, mode }) => { |
|
|
|
|
|
const env = loadEnv(mode, process.cwd()) // 获取 .env里面定义是参数 |
|
|
|
|
|
|
|
|
|
|
|
console.log('env', env, mode, command) |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
|
transpileDependencies: ['uview-ui'], |
|
|
|
|
|
plugins: [ |
|
|
|
|
|
uni(), |
|
|
|
|
|
], |
|
|
|
|
|
server: { |
|
|
|
|
|
host: "0.0.0.0", |
|
|
|
|
|
port: '8591', |
|
|
|
|
|
open: false, // 运行是否自动打开浏览器 |
|
|
|
|
|
proxy: { |
|
|
|
|
|
// 反向代理解决跨域 |
|
|
|
|
|
"/api": { |
|
|
|
|
|
target: env.VITE_APP_BASE_URL, // 线上接口地址 |
|
|
|
|
|
changeOrigin: true, |
|
|
|
|
|
rewrite: (path) => path.replace(/^\/api/, ""), |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |