wireguard-dashboard-admin/vite.config.js

41 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'
import { createViteProxy, viteDefine } from './build/config'
2022-05-03 22:37:51 +08:00
import { createVitePlugins } from './build/plugin'
2022-01-08 17:20:46 +08:00
import { OUTPUT_DIR } from './build/constant'
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)
const { VITE_PORT, VITE_PUBLIC_PATH, VITE_USE_PROXY, VITE_PROXY_TYPE } = 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
},
},
2022-08-27 14:09:32 +08:00
define: viteDefine,
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,
proxy: createViteProxy(VITE_USE_PROXY, VITE_PROXY_TYPE),
2022-01-08 17:20:46 +08:00
},
build: {
target: 'es2015',
outDir: OUTPUT_DIR,
2022-05-19 15:40:02 +08:00
reportCompressedSize: false, // 启用/禁用 gzip 压缩大小报告
chunkSizeWarningLimit: 1024, // chunk 大小警告的限制单位kb
2022-01-08 17:20:46 +08:00
},
}
})