-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvue.config.js
67 lines (63 loc) · 1.72 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
/*
* @Author: shen
* @Date: 2021-01-23 08:13:27
* @LastEditors: shen
* @LastEditTime: 2021-02-04 23:20:47
* @Description:
*/
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path')
const CompressionPlugin = require('compression-webpack-plugin')
const WebpackDynamicThemePlugin = require('webpack-dynamic-theme-plugin')
function resolve(dir) {
return path.join(__dirname, dir)
}
function addStyleResource(rule) {
rule
.use('style-resource')
.loader('style-resources-loader')
.options({
patterns: [path.resolve(__dirname, './src/assets/styles/variables.scss'), path.resolve(__dirname, './src/assets/styles/mixins.scss')],
})
}
module.exports = {
productionSourceMap: false,
configureWebpack: () => {
const plugins = [
new WebpackDynamicThemePlugin({
theme: '#409eff',
}),
]
if (process.env.NODE_ENV === 'production') {
plugins.push(
new CompressionPlugin({
test: /\.js$|\.html$|\.css$/, // 匹配文件名
threshold: 10240, // 对超过10k的数据压缩
deleteOriginalAssets: false, // 不删除源文件
}),
)
}
return {
plugins,
}
},
chainWebpack: (config) => {
const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
types.forEach((type) => addStyleResource(config.module.rule('sass').oneOf(type)))
config.module
.rule('svg')
.exclude.add(resolve('src/assets/icons'))
.end()
config.module
.rule('icons')
.test(/\.svg$/)
.include.add(resolve('src/assets/icons'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]',
})
.end()
},
}