-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
55 lines (51 loc) · 1.58 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
const { defineConfig } = require('@vue/cli-service')
const path = require('path')
const dayjs = require('dayjs')
function resolve(dir) {
return path.join(__dirname, dir)
}
const isEnvProduction = process.env.NODE_ENV === 'production'
// 注入版本信息
process.env.VUE_APP_VERSION = require('./package.json').version
// 注入版本更新时间
process.env.VUE_APP_UPDATE_TIME = dayjs().locale('zh-cn').format('YYYY-MM-DD')
module.exports = defineConfig({
publicPath: '',
chainWebpack(config) {
config.resolve.alias
.set('api', resolve('src/api'))
.set('assets', resolve('src/assets'))
.set('base', resolve('src/base'))
.set('components', resolve('src/components'))
.set('pages', resolve('src/pages'))
config.plugin('html').tap((args) => {
if (isEnvProduction) {
if (!args[0].minify) {
/* 参考 https://github.com/jantimon/html-webpack-plugin#minification */
args[0].minify = {
collapseWhitespace: true,
keepClosingSlash: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true,
trimCustomFragments: true
}
}
args[0].minify.minifyJS = true
args[0].minify.minifyCSS = true
}
return args
})
},
pluginOptions: {
'style-resources-loader': {
preProcessor: 'less',
patterns: [
resolve('src/styles/var.less'),
resolve('src/styles/mixin.less')
]
}
}
})