-
Notifications
You must be signed in to change notification settings - Fork 116
/
vite.config.js
61 lines (60 loc) · 1.31 KB
/
vite.config.js
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
59
60
61
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
import { visualizer } from 'rollup-plugin-visualizer';
export default defineConfig({
plugins: [
vue(),
visualizer({
open: true,
}),
Components({
resolvers: [
AntDesignVueResolver({
importStyle: false,
resolveIcons: true,
}),
],
}),
],
server: {
port: 3000,
host: '0.0.0.0',
},
resolve: {
alias: {
'@': '/src',
},
},
css: {
preprocessorOptions: {
less: {
modifyVars: {
hack: `true; @import "~ant-design-vue/lib/style/themes/dark.less";`,
},
javascriptEnabled: true,
},
},
},
build: {
// 添加 build 配置
rollupOptions: {
output: {
// 手动拆分 chunk
manualChunks(id) {
if (id.includes('node_modules')) {
if (id.includes('ant-design-vue')) {
return 'ant-design-vue';
}
if (id.includes('lodash')) {
return 'lodash';
}
// 添加更多需要单独拆分的库
return 'vendor';
}
},
},
},
},
});