-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
90 lines (89 loc) · 2.42 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import eslintPlugin from 'vite-plugin-eslint';
import viteCompression from 'vite-plugin-compression';
import { resolve } from 'path';
import { visualizer } from 'rollup-plugin-visualizer';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
eslintPlugin({
include: ['src/**/*.js', 'src/**/*.vue', 'src/*.js', 'src/*.vue'],
// cache: false,
}),
viteCompression({
algorithm: 'gzip',
threshold: 10240, // 压缩限制
}),
visualizer({
open: true,
}),
],
resolve: {
alias: {
'@': resolve(__dirname, './src'),
},
},
/* css: {
preprocessorOptions: {
less: { // 静态自定义样式
modifyVars: {
'primary-color': 'green',
'link-color': '#1DA57A',
'border-radius-base': '2px',
},
javascriptEnabled: true,
},
},
}, */
server: {
host: true,
open: true,
proxy: {
'/api': {
target: 'http://127.0.0.1:4523', // dev
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
build: {
chunkSizeWarningLimit: 2000,
cssCodeSplit: true, // css 拆分
sourcemap: false, // 不生成sourcemap
minify: 'terser', // 是否禁用最小化混淆,esbuild打包速度最快,terser打包体积最小。
assetsInlineLimit: 5000, // 小于该值 图片将打包成Base64
terserOptions: {
compress: {
// 生产环境时移除console.log()
drop_console: true,
drop_debugger: true,
},
},
rollupOptions: {
// 两种方式
// 一,也可以指定包名打包
output: {
manualChunks: {
'ant-design-vue': ['ant-design-vue'],
'@antv/data-set': ['@antv/data-set'],
'@antv/g2': ['@antv/g2'],
'@antv/g2plot': ['@antv/g2plot'],
},
},
// 二,自动分割包名输出 chunkSizeWarningLimit 配置大小
/* output: {
chunkFileNames: 'assets/js/[name]-[hash].js',
entryFileNames: 'assets/js/[name]-[hash].js',
assetFileNames: 'assets/static/[name]-[hash].[ext]',
manualChunks(id: any) {
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString();
}
return '';
},
}, */
},
},
});