-
Notifications
You must be signed in to change notification settings - Fork 50
/
vue.config.js
74 lines (73 loc) · 1.8 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
70
71
72
73
74
/*
* @file: vue.config.js
* @copyright: BoBo
* @author: BoBo
* @Date: 2020年10月28 10:44:39
*/
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const TerserPlugin = require('terser-webpack-plugin');
const path = require('path');
function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports = {
productionSourceMap: false,
// 将 examples 目录添加为新的页面
pages: {
index: {
// page 的入口
entry: 'examples/main.ts',
// 模板来源
template: 'examples/index.html',
// 输出文件名
filename: 'index.html',
},
},
chainWebpack: (config) => {
if (process.env.IS_REPORT) {
config.plugin('webpack-report').use(BundleAnalyzerPlugin, [
{
analyzerMode: 'static',
},
]);
}
config.module
.rule('svg')
.exclude.add(resolve('src/icons'));
// 添加svg-sprite-loader加载器
config.module
.rule('svg-sprite-loader')
.test(/.svg$/)
.include.add(resolve('src/icons')) // 处理svg目录
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]',
})
.end()
.use('svgo-loader')
.loader('svgo-loader')
.end();
},
configureWebpack: (config) => {
config.resolve.alias['@'] = resolve('src');
config.resolve.alias.packages = resolve('packages');
const plugins = [
new TerserPlugin({
terserOptions: {
compress: {
warnings: false,
drop_debugger: false,
drop_console: true,
},
},
sourceMap: false,
parallel: true,
}),
];
if (process.env.NODE_ENV !== 'development') {
config.plugins = [...config.plugins, ...plugins];
}
},
};