fix: 手动打包 Proxy 问题(#91)

* perf: 检查代码

* feat: proxy setting

* chore: 调整为测试环境使用 `proxy`
This commit is contained in:
Redon
2023-02-22 14:29:05 +08:00
committed by GitHub
parent 66cecb6049
commit bf5c0cdf04
8 changed files with 28 additions and 16 deletions

View File

@@ -1,10 +1,13 @@
import path from 'path'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import { createViteProxy } from './config'
export default defineConfig((env) => {
const viteEnv = loadEnv(env.mode, process.cwd()) as unknown as ImportMetaEnv
const isOpenProxy = viteEnv.VITE_GLOB_HTTP_PROXY === 'Y'
return {
resolve: {
alias: {
@@ -13,16 +16,10 @@ export default defineConfig((env) => {
},
plugins: [vue()],
server: {
port: 1002,
host: '0.0.0.0',
port: 1002,
open: false,
proxy: {
'/api': {
target: viteEnv.VITE_APP_API_BASE_URL,
changeOrigin: true, // 允许跨域
rewrite: path => path.replace('/api/', '/'),
},
},
proxy: createViteProxy(isOpenProxy, viteEnv),
},
build: {
reportCompressedSize: false,