-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
51 lines (50 loc) · 1.42 KB
/
Copy pathvite.config.js
File metadata and controls
51 lines (50 loc) · 1.42 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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig({
base: './',
plugins: [
vue(),
AutoImport({
resolvers: [ElementPlusResolver()],
imports: ['vue', 'vue-router', 'pinia']
}),
Components({
resolvers: [ElementPlusResolver()]
})
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src')
}
},
server: {
port: 4321
},
publicDir: 'public',
// 构建配置 - 代码混淆和加密
build: {
// 使用 terser 进行代码压缩
minify: 'terser',
// terser 压缩选项
terserOptions: {
// 压缩选项
compress: {
drop_console: true, // 移除所有 console.log 语句
drop_debugger: true // 移除所有 debugger 语句
},
// 混淆选项
mangle: {
toplevel: true // 混淆顶层作用域的变量名
},
// 格式化选项
format: {
comments: false // 移除所有注释
}
}
}
})