mirror of
https://github.com/chansee97/nova-admin.git
synced 2025-04-05 04:22:49 +08:00
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
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', 'quill'],
|
|
},
|
|
css: {
|
|
preprocessorOptions: {
|
|
scss: {
|
|
api: 'modern',
|
|
},
|
|
},
|
|
},
|
|
}
|
|
})
|