This commit is contained in:
mizhexiaoxiao
2023-08-17 14:32:31 +08:00
parent 52bd125538
commit fbcdb3ca4d
10 changed files with 38 additions and 47 deletions
+10 -4
View File
@@ -1,8 +1,9 @@
import { defineConfig, loadEnv } from 'vite'
import { convertEnv, getSrcPath, getRootPath } from './build/utils'
import { createViteProxy, viteDefine } from './build/config'
import { viteDefine } from './build/config'
import { createVitePlugins } from './build/plugin'
import { OUTPUT_DIR, PROXY_CONFIG } from './build/constant'
export default defineConfig(({ command, mode }) => {
const srcPath = getSrcPath()
@@ -11,7 +12,8 @@ export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd())
const viteEnv = convertEnv(env)
const { VITE_PORT, VITE_PUBLIC_PATH, VITE_USE_PROXY, VITE_PROXY_TYPE } = viteEnv
const { VITE_PORT, VITE_PUBLIC_PATH, VITE_USE_PROXY, VITE_BASE_API } = viteEnv
return {
base: VITE_PUBLIC_PATH || '/',
resolve: {
@@ -26,11 +28,15 @@ export default defineConfig(({ command, mode }) => {
host: '0.0.0.0',
port: VITE_PORT,
open: true,
proxy: createViteProxy(VITE_USE_PROXY, VITE_PROXY_TYPE),
proxy: VITE_USE_PROXY
? {
[VITE_BASE_API]: PROXY_CONFIG[VITE_BASE_API],
}
: undefined,
},
build: {
target: 'es2015',
outDir: 'dist',
outDir: OUTPUT_DIR || 'dist',
reportCompressedSize: false, // 启用/禁用 gzip 压缩大小报告
chunkSizeWarningLimit: 1024, // chunk 大小警告的限制(单位kb)
},