nova-admin/vite.config.ts
2024-03-28 23:35:52 +08:00

35 lines
1006 B
TypeScript

import { resolve } from 'node:path'
import { defineConfig, loadEnv } from 'vite'
import { createVitePlugins } from './build/plugins'
import { createViteProxy } from './build/proxy'
import { serviceConfig } from './service.config'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
// 根据当前工作目录中的 `mode` 加载 .env 文件
const env = loadEnv(mode, __dirname, '') as ImportMetaEnv
const envConfig = serviceConfig[mode as ServiceEnvType]
return {
base: env.VITE_BASE_URL,
plugins: createVitePlugins(env),
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
},
},
server: {
host: '0.0.0.0',
proxy:
env.VITE_HTTP_PROXY === 'Y' ? createViteProxy(envConfig) : undefined,
},
build: {
target: 'esnext',
reportCompressedSize: false, // 启用/禁用 gzip 压缩大小报告
},
optimizeDeps: {
include: ['echarts', 'md-editor-v3', '@tinymce/tinymce-vue'],
},
}
})