feat(projects): 添加网络代理

This commit is contained in:
Soybean
2022-03-12 19:32:15 +08:00
parent 8191490f39
commit 094dca961f
24 changed files with 75 additions and 50 deletions

View File

@ -1,6 +1,7 @@
import { fileURLToPath } from 'url';
import { defineConfig, loadEnv } from 'vite';
import { setupVitePlugins, define } from './build';
import { getEnvConfig } from './.env-config';
export default defineConfig((configEnv) => {
const viteEnv = loadEnv(configEnv.mode, `.env.${configEnv.mode}`) as ImportMetaEnv;
@ -8,6 +9,8 @@ export default defineConfig((configEnv) => {
const srcPath = fileURLToPath(new URL('./src', import.meta.url));
const rootPath = fileURLToPath(new URL('./', import.meta.url));
const { http } = getEnvConfig(viteEnv);
return {
base: viteEnv.VITE_BASE_URL,
resolve: {
@ -32,6 +35,13 @@ export default defineConfig((configEnv) => {
host: '0.0.0.0',
port: 3200,
open: true,
proxy: {
[http.proxy]: {
target: http.url,
changeOrigin: true,
rewrite: (path) => path.replace(new RegExp(`^${http.proxy}`), ''),
},
},
},
build: {
brotliSize: false,