-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
77 lines (76 loc) · 1.79 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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import tailwindcss from '@tailwindcss/vite';
import path from 'path';
import viteCompression from 'vite-plugin-compression';
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
tailwindcss(),
viteCompression({
verbose: true,
disable: false,
threshold: 10240,
algorithm: 'gzip',
}),
],
// 配置分包
build: {
// 压缩css代码
cssCodeSplit: true,
// js代码压缩
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
mangle: {
toplevel: true,
}
},
rollupOptions: {
output: {
chunkFileNames: 'static/js/[name]-[hash].js',
// 按文件类型进行拆分文件夹
assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
manualChunks: {
react: ['react', 'react-dom', 'react-router-dom'],
antd: ['antd'],
// 拆分图标库
'ant-icons': ['@ant-design/icons'],
echarts: ['echarts'],
axios: ['axios'],
logicFlow: ['@logicflow/core','@logicflow/extension'],
},
},
},
},
// 配置路径别名解析
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
},
// css预处理器
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "@/styles/variables.scss";`,
},
},
},
// 服务器配置以及代理
server: {
port: 3000,
proxy: {
'/api': {
target: 'http://localhost:8090/fusion',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
});