-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
95 lines (92 loc) · 2.38 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* eslint-disable prettier/prettier */
const webpack = require('webpack');
const path = require('path');
function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports = {
// 生产环境打包不输出 map
productionSourceMap: false,
devServer: {
disableHostCheck: true,
port: process.env.DEV_SERVER_PORT || 8080,
proxy: {
'^/api': {
target: 'http://localhost:3000',
changeOrigin: true,
pathRewrite: {
'^/api': '/',
},
},
},
},
pwa: {
name: 'VueMusic',
iconPaths: {
favicon32: 'img/icons/favicon-32x32.png',
},
themeColor: '#ffffff00',
manifestOptions: {
background_color: '#335eea',
},
// workboxOptions: {
// swSrc: "dev/sw.js",
// },
},
// 用于多页配置
pages: {
index: {
entry: 'src/main.js',
template: 'public/index.html',
filename: 'index.html',
title: 'VueMusic',
chunks: ['main', 'chunk-vendors', 'chunk-common', 'index'],
},
},
chainWebpack(config) {
// 分析分包大小
if (process.env.npm_config_report) {
config
.plugin('webpack-bundle-analyzer')
.use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
.end();
}
//忽略的打包文件
// config.externals({
// vue: 'Vue',
// 'vue-router': 'VueRouter',
// vuex: 'Vuex',
// axios: 'axios',
// lodash: 'lodash',
// });
config.resolve.alias.set('@', resolve('src')); // key,value自行定义,比如.set('@@', resolve('src/components'))
config.module.rules.delete('svg');
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();
config.module
.rule('napi')
.test(/\.node$/)
.use('node-loader')
.loader('node-loader')
.end();
// LimitChunkCountPlugin 可以通过合并块来对块进行后期处理。用以解决 chunk 包太多的问题
config.plugin('chunkPlugin').use(webpack.optimize.LimitChunkCountPlugin, [
{
maxChunks: 3,
minChunkSize: 10_000,
},
]);
},
// 添加插件的配置
pluginOptions: {},
};