-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.js
65 lines (64 loc) · 1.46 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
62
63
64
65
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteCompression from 'vite-plugin-compression';
export default defineConfig({
plugins: [
react(),
viteCompression({
algorithm: 'brotliCompress', // 使用 Brotli 压缩
ext: '.br',
threshold: 1024, // 仅压缩大于 1KB 的文件
}),
viteCompression({
algorithm: 'gzip', // 额外生成 gzip 文件
ext: '.gz',
threshold: 1024,
}),
],
build: {
commonjsOptions: {
transformMixedEsModules: true
},
outDir: 'dist',
rollupOptions: {
output: {
assetFileNames: '[name].[hash].[ext]',
manualChunks(id) {
if (id.includes('node_modules')) {
return 'vendor';
}
if (id.includes('jspdf')) {
return 'jspdf';
}
if (id.includes('speed-insights')) {
return 'speed-insights';
}
},
},
},
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
pure_funcs: ['console.log'],
},
format: {
comments: false,
},
},
},
server: {
port: 3000,
open: true,
historyApiFallback: true,
},
resolve: {
extensions: ['.js', '.jsx'],
},
test: {
environment: 'happy-dom',
globals: true,
setupFiles: './src/setupTests.js', // load setupTests.js
css: true, // enable CSS imports during testing
},
});