-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
58 lines (52 loc) · 1.55 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { fileURLToPath, URL } from 'node:url';
import type { UserConfig, ConfigEnv } from 'vite';
import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import { vitePluginConfig } from './build';
import { transformEnvConfType } from './build/utils';
import { createProxy } from './build/proxy';
// https://vitejs.dev/config/
export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
const root = process.cwd();
const viteEnv = transformEnvConfType(loadEnv(mode, root));
const { VITE_DROP_CONSOLE, VITE_PORT, VITE_PROXY } = viteEnv;
return {
plugins: [
vue({ include: [/\.vue$/, /\.md$/] }),
vueJsx(),
// ext vite plugin
vitePluginConfig(viteEnv),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'#': fileURLToPath(new URL('./types', import.meta.url)),
},
},
server: {
https: false,
// Listening on all local IPs
host: true,
port: VITE_PORT,
// Load proxy configuration from .env
proxy: createProxy(VITE_PROXY),
},
esbuild: {
// 移除日志打印及debugger
drop: VITE_DROP_CONSOLE ? ['console', 'debugger'] : [],
},
// 处理ant-design-vue 样式文件
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
// 依赖优化 - 预构建
optimizeDeps: {
include: ['vue', 'pinia', 'vue-router', 'ant-design-vue/es', '@vueuse/core'],
},
};
});