-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathvue.config.js
144 lines (138 loc) · 4.35 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
const path = require('path')
const defaultSettings = require('./src/config')
const MonacoEditorPlugin = require('monaco-editor-webpack-plugin')
const siteName = defaultSettings.siteName || 'vue-iview-admin-template'
const resolve = dir => path.join(__dirname, '.', dir)
module.exports = {
// publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
devServer: {
port: 9000,
open: true
},
productionSourceMap: process.env.NODE_ENV !== 'production',
css: {
loaderOptions: {
less: {
modifyVars: {
hack: `true; @import "~@/themes/variables.less";`
},
javascriptEnabled: true
}
}
},
transpileDependencies: ['vue-echarts', 'resize-detector'],
chainWebpack: config => {
config.plugin('html').tap(args => {
args[0].title = siteName
return args
})
config.module
.rule('svg')
.exclude.add(resolve('src/assets/icons/svg'))
.end()
config.module
.rule('icons')
.test(/\.svg$/)
.include.add(resolve('src/assets/icons/svg'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]'
})
config.module
.rule('vue')
.test(/\.vue$/)
.use('iview-loader')
.loader('iview-loader')
.options({
prefix: true
})
// SplitChunksPlugin https://webpack.js.org/plugins/split-chunks-plugin/
const splitOptions = config.optimization.get('splitChunks')
config.optimization.splitChunks(
Object.assign({}, splitOptions, {
// (缺省值5)按需加载时的最大并行请求数
maxAsyncRequests: 16,
// (默认值3)入口点上的最大并行请求数
maxInitialRequests: 16,
// (默认值:1)分割前共享模块的最小块数
minChunks: 1,
// (默认值:30000)块的最小大小
minSize: 30000,
// webpack 将使用块的起源和名称来生成名称: `vendors~main.js`,如项目与"~"冲突,则可通过此值修改,Eg: '-'
automaticNameDelimiter: '~',
// cacheGroups is an object where keys are the cache group names.
name: true,
cacheGroups: {
default: false,
common: {
name: 'chunk-common',
chunks: 'initial',
minChunks: 2,
maxInitialRequests: 8,
minSize: 0,
// 默认组的优先级为负数,以允许任何自定义缓存组具有更高的优先级(默认值为0)
priority: 1,
reuseExistingChunk: true
},
// vendors: {
// name: 'chunk-vendors',
// test: /[\\/]node_modules[\\/]/,
// chunks: 'initial',
// priority: 2,
// reuseExistingChunk: true
// },
viewDesign: {
name: 'chunk-view-design',
test: /[\\/]node_modules[\\/]view-design[\\/]/,
chunks: 'all',
priority: 3,
reuseExistingChunk: true
},
echarts: {
name: 'chunk-echarts',
test: /[\\/]node_modules[\\/](vue-)?echarts[\\/]/,
chunks: 'all',
priority: 4,
reuseExistingChunk: true
},
components: {
name: 'chunk-components',
test: resolve('src/components'),
minChunks: 3,
priority: 0,
reuseExistingChunk: true
},
monacoEditor: {
name: 'chunk-monaco-editor',
test: /[\\/]node_modules[\\/]monaco-editor[\\/]/,
chunks: 'all',
priority: 4
},
cesium: {
name: 'chunk-cesium',
test: /[\\/]node_modules[\\/]cesium[\\/]/,
chunks: 'all',
priority: 5
}
}
})
)
},
configureWebpack: config => {
const plugins = [
new MonacoEditorPlugin({
// https://github.com/Microsoft/monaco-editor-webpack-plugin#options
// Include a subset of languages support
// Some language extensions like typescript are so huge that may impact build performance
// e.g. Build full languages support with webpack 4.0 takes over 80 seconds
// Languages are loaded on demand at runtime
languages: ['json', 'html']
})
]
return {
plugins: plugins
}
}
}