wireguard-dashboard-admin/vite.config.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-01-08 17:20:46 +08:00
import { defineConfig, loadEnv } from 'vite'
2022-08-27 14:09:32 +08:00
import { convertEnv, getSrcPath, getRootPath } from './build/utils'
2022-05-03 22:37:51 +08:00
import { createVitePlugins } from './build/plugin'
2023-06-21 21:53:33 +08:00
import { OUTPUT_DIR, PROXY_CONFIG } from './build/constant'
2022-01-08 17:20:46 +08:00
export default defineConfig(({ command, mode }) => {
2022-08-27 14:09:32 +08:00
const srcPath = getSrcPath()
const rootPath = getRootPath()
2022-01-08 17:20:46 +08:00
const isBuild = command === 'build'
const env = loadEnv(mode, process.cwd())
2022-08-27 14:09:32 +08:00
const viteEnv = convertEnv(env)
2023-06-21 21:53:33 +08:00
const { VITE_PORT, VITE_PUBLIC_PATH, VITE_USE_PROXY, VITE_BASE_API } = viteEnv
2022-01-08 17:20:46 +08:00
return {
base: VITE_PUBLIC_PATH || '/',
resolve: {
alias: {
2022-08-27 14:09:32 +08:00
'~': rootPath,
'@': srcPath,
2022-01-08 17:20:46 +08:00
},
},
plugins: createVitePlugins(viteEnv, isBuild),
server: {
host: '0.0.0.0',
port: VITE_PORT,
2022-08-27 14:09:32 +08:00
open: false,
2023-06-21 21:53:33 +08:00
proxy: VITE_USE_PROXY
? {
[VITE_BASE_API]: PROXY_CONFIG[VITE_BASE_API],
'/api/v2': PROXY_CONFIG['/api/v2'],
}
: undefined,
2022-01-08 17:20:46 +08:00
},
build: {
target: 'es2015',
2023-06-21 21:53:33 +08:00
outDir: OUTPUT_DIR || 'dist',
2022-05-19 15:40:02 +08:00
reportCompressedSize: false, // 启用/禁用 gzip 压缩大小报告
chunkSizeWarningLimit: 1024, // chunk 大小警告的限制单位kb
2022-01-08 17:20:46 +08:00
},
}
})