ci(other): cicd
This commit is contained in:
60
vite.config.js
Normal file
60
vite.config.js
Normal file
@@ -0,0 +1,60 @@
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
|
||||
import { convertEnv, getSrcPath, getRootPath } from './build/utils'
|
||||
import { createVitePlugins } from './build/plugin'
|
||||
import { OUTPUT_DIR, PROXY_CONFIG } from './build/constant'
|
||||
|
||||
export default defineConfig(({ command, mode }) => {
|
||||
const srcPath = getSrcPath()
|
||||
const rootPath = getRootPath()
|
||||
const isBuild = command === 'build'
|
||||
|
||||
const env = loadEnv(mode, process.cwd())
|
||||
const viteEnv = convertEnv(env)
|
||||
const {
|
||||
VITE_PORT,
|
||||
VITE_PUBLIC_PATH,
|
||||
VITE_USE_PROXY,
|
||||
VITE_BASE_API,
|
||||
VITE_ADMIN_API,
|
||||
VITE_SENTRY,
|
||||
} = viteEnv
|
||||
|
||||
// 调试代理配置
|
||||
console.log('=== Vite代理配置调试 ===')
|
||||
console.log('VITE_USE_PROXY:', VITE_USE_PROXY)
|
||||
console.log('VITE_BASE_API:', VITE_BASE_API)
|
||||
console.log('VITE_ADMIN_API:', VITE_ADMIN_API)
|
||||
console.log('PROXY_CONFIG:', PROXY_CONFIG)
|
||||
console.log('所有环境变量:', viteEnv)
|
||||
|
||||
return {
|
||||
base: VITE_PUBLIC_PATH || '/',
|
||||
resolve: {
|
||||
alias: {
|
||||
'~': rootPath,
|
||||
'@': srcPath,
|
||||
},
|
||||
},
|
||||
plugins: createVitePlugins(viteEnv, isBuild),
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
https: false,
|
||||
port: VITE_PORT,
|
||||
open: false,
|
||||
proxy: {
|
||||
'/api1': PROXY_CONFIG['/api1'],
|
||||
'/api': PROXY_CONFIG['/api'],
|
||||
'/admin1': PROXY_CONFIG['/admin1'],
|
||||
'/admin': PROXY_CONFIG['/admin'],
|
||||
},
|
||||
},
|
||||
build: {
|
||||
target: 'es2015',
|
||||
outDir: OUTPUT_DIR || 'dist',
|
||||
reportCompressedSize: false, // 启用/禁用 gzip 压缩大小报告
|
||||
chunkSizeWarningLimit: 1024, // chunk 大小警告的限制(单位kb)
|
||||
sourcemap: VITE_SENTRY,
|
||||
},
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user