vue.config.js
3.16 KB
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
96
const CompressionPlugin = require('compression-webpack-plugin');
const webpack = require('webpack');
const WebpackBar = require('webpackbar');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
module.exports = {
publicPath: '/mvue',
runtimeCompiler: true,
// devServer: {
// port: 7006,
// // proxy: 'http://192.168.3.15:60011',
// proxy: 'http://localhost:60011/api'
// },
configureWebpack: config => {
config.plugins = [
...config.plugins,
new WebpackBar({
name: 'eip-manage',
}),
new webpack.IgnorePlugin({
resourceRegExp: /^\.\/locale$/,
contextRegExp: /moment$/
}),
new MonacoWebpackPlugin({languages: ['javascript', 'css', 'html', 'typescript', 'json', 'java']})
]
if (process.env.NODE_ENV === 'production') {
// gzip压缩
config.plugins = [
...config.plugins,
new CompressionPlugin({
// 要压缩的文件类型
test: /\.js$|\.html$|\.css/,
// 大于该尺寸的文件才压缩(单位byte)
threshold: 10240,
// 是否删除原文件
deleteOriginalAssets: false
}),
];
}
},
chainWebpack: config => {
config.plugins.delete('preload')
config.plugins.delete('prefetch')
config.devServer.disableHostCheck(true);
config.entry('index').add('babel-polyfill');
if (process.env.NODE_ENV === 'production') {
config.performance.set('hints', false)
config.devtool('none')
// 配置打包时分包的数量上限和单个文件的最小尺寸
config.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
elementUI: {
name: 'chunk-elementUI',
priority: 20,
test: /[\\/]node_modules[\\/]_?element-ui(.*)/,
},
hotentUI: {
name: 'chunk-hotentUI',
priority: 20,
test: /[\\/]node_modules[\\/]_?hotent-ui(.*)/,
},
},
})
}
// bpmnlink
config.module
.rule('bpmn')
.test(/\.bpmn$/)
.use('raw-loader')
.loader('raw-loader')
.tap(options => {
// 修改它的选项...
return options
})
// bpmnlink
config.module
.rule('bpmnlint')
.test(/\.bpmnlintrc$/)
.use('bpmnlint-loader')
.loader('bpmnlint-loader')
.tap(options => {
// 修改它的选项...
return options
})
},
// 不生成sourceMap
productionSourceMap: false,
css: {
loaderOptions: {
sass: {
prependData: `@import "~@/assets/css/element-variables.scss";`
},
},
},
}