This repository has been archived by the owner on Mar 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
75 lines (74 loc) · 1.97 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
66
67
68
69
70
71
72
73
74
75
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import {resolve} from 'path'
import viteSvgIcons from 'vite-plugin-svg-icons'
import styleImport from 'vite-plugin-style-import'
import pxtorem from 'postcss-pxtorem'
export default defineConfig({
base: "./",
plugins: [
vue(),
// vant按需引入
styleImport({
libs: [
{
libraryName: 'vant',
esModule: true,
resolveStyle: (name) => `vant/es/${name}/style/index`,
},
],
}),
viteSvgIcons({
// 指定需要缓存的图标文件夹
iconDirs: [resolve(process.cwd(), 'src/icons/svg')],
// 指定symbolId格式
symbolId: 'icon-[dir]-[name]',
})
],
// 文件夹别名 @ 为src目录
resolve: {
alias: {
'@': resolve(__dirname, 'src')
}
},
css: {
postcss: {
plugins: [
pxtorem({
rootValue: 39,
propList: ['*']
})
]
},
},
server: {
// 服务器启动时自动在浏览器中打开
open: true,
host: '0.0.0.0'
},
build: {
// 指定输出路径
outDir: 'dist',
// 在 outDir 中生成 manifest.json
manifest: false,
//生成静态资源的存放路径
assetsDir: "assets",
//自定义底层的 Rollup 打包配置
rollupOptions: {
output: {
chunkFileNames: 'js/[name]-[hash].js',
entryFileNames: 'js/[name]-[hash].js'
},
},
//启用/禁用 brotli 压缩大小报告
brotliSize: false,
minify: 'terser',
// 删除console
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true
}
}
}
})