-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.js
More file actions
54 lines (53 loc) · 1.14 KB
/
vite.config.js
File metadata and controls
54 lines (53 loc) · 1.14 KB
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
import { defineConfig } from 'vite'
import path from 'path'
export default defineConfig({
root: '.',
build: {
outDir: 'dist',
target: 'es2020',
// 优化构建性能
minify: 'esbuild',
sourcemap: false,
// 代码分割优化
rollupOptions: {
input: './index.html',
output: {
manualChunks: {
'echarts': ['echarts']
}
}
}
},
server: {
port: 3000,
open: true,
// 开发服务器优化
hmr: {
overlay: true
}
},
resolve: {
extensions: ['.js', '.ts', '.json'],
// 添加路径别名,简化导入
alias: {
'@': path.resolve(__dirname, 'src'),
'@components': path.resolve(__dirname, 'src/components'),
'@utils': path.resolve(__dirname, 'src/utils'),
'@styles': path.resolve(__dirname, 'src/styles')
}
},
optimizeDeps: {
include: ['echarts'],
// 预构建优化
force: false
},
esbuild: {
target: 'es2020',
// 移除 console 和 debugger(生产环境)
drop: process.env.NODE_ENV === 'production' ? ['console', 'debugger'] : []
},
// CSS 优化
css: {
devSourcemap: true
}
})