-
Notifications
You must be signed in to change notification settings - Fork 163
/
vite.config.ts
41 lines (39 loc) · 1.07 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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',
},
},
},
}
})