-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
85 lines (74 loc) · 1.72 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
76
77
78
79
80
81
82
83
84
85
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import path from 'path'
// import viteImagemin from 'vite-plugin-imagemin'
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
swiper: path.resolve(__dirname, 'node_modules/swiper/'),
},
},
build: {
minify: 'esbuild',
},
plugins: [
vue({
css: false, // 重要:vue 单文件中的样式提取为单个文件
}),
createSvgIconsPlugin({
// 指定需要缓存的图标文件夹
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
// 指定symbolId格式
symbolId: 'icon__[dir]/[name]',
/**
* 自定义插入位置
* @default: body-last
*/
inject: 'body-last',
/**
* custom dom id
* @default: __svg__icons__dom__
*/
customDomId: '__svg__icons__dom__',
}),
// viteImagemin({
// gifsicle: {
// optimizationLevel: 8,
// interlaced: false,
// },
// optipng: {
// optimizationLevel: 9,
// },
// mozjpeg: {
// quality: 85,
// },
// pngquant: {
// quality: [0.8, 0.9],
// speed: 4,
// },
// svgo: {
// plugins: [
// {
// name: 'removeViewBox',
// },
// {
// name: 'removeEmptyAttrs',
// active: false,
// },
// ],
// },
// }),
],
ssr: {
format: 'cjs',
// 重要
// noExternal: ['swiper'],
external: ['@amap/amap-jsapi-loader'],
},
server: {
host: '0.0.0.0',
},
})