forked from imoyao/GUSCSS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
69 lines (69 loc) · 1.94 KB
/
vue.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
var ImageminPlugin = require('imagemin-webpack-plugin').default
// 生产模式使用cdn
function getProdExternals () {
return {
vue: 'Vue',
'element-ui': 'ElementUI',
}
}
module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? '/' : '/',
// 输出文件目录
outputDir: 'docs',
pwa: {
themeColor: '#ffffff',
msTileColor: '#ffffff',
workboxOptions: {
skipWaiting: true,
clientsClaim: true,
},
iconPaths: {
favicon32: 'img/icons/fuji-mountain-32x32.png',
favicon16: 'img/icons/fuji-mountain-16x16.png',
appleTouchIcon: 'img/icons/apple-touch-icon-152x152.png',
maskIcon: 'img/icons/safari-pinned-tab.svg',
msTileImage: 'img/icons/msapplication-icon-144x144.png',
},
},
lintOnSave: process.env.NODE_ENV !== 'production',
devServer: {
overlay: {
warnings: true,
errors: true,
},
},
configureWebpack: {
// https://www.dongwm.com/post/optimize-vue-admin/
// see also: https://www.cnblogs.com/xbzhu/p/11815197.html
// see also: https://blog.csdn.net/qq_35844177/article/details/78599064
externals: process.env.NODE_ENV === 'production'
? getProdExternals() : {},
plugins: [
new ImageminPlugin({
disable: true, // Disable for windows
// disable: process.env.NODE_ENV !== 'production', // Disable during development
pngquant: {
quality: '80',
},
}),
],
},
chainWebpack: config => {
config.resolve.symlinks(true)
config.plugin('preload').tap(options => {
options[0] = {
rel: 'preload',
as (entry) {
if (/\.css$/.test(entry)) return 'style'
if (/\.(woff||ttf)$/.test(entry)) return 'font'
if (/\.png$/.test(entry)) return 'image'
return 'script'
},
include: 'allAssets',
fileBlacklist: [ /\.map$/, /hot-update\.js$/ ],
}
return options
})
return config
},
}