-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvue.config.package.js
116 lines (110 loc) · 3.02 KB
/
vue.config.package.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
/*
* @description: 打包的配置
* @Author: xing.heng
*/
const path = require('path')
const { ProvidePlugin } = require('webpack')
const CompressionPlugin = require('compression-webpack-plugin')
function resolve (dir) {
return path.join(__dirname, dir)
}
module.exports = {
lintOnSave: false,
css: {
extract: true
},
configureWebpack: {
externals: {
vuex: 'vuex',
vue: 'vue',
vueRouter: 'vue-router',
'@antv/g2plot': '@antv/g2plot',
'@jiaminghi/data-view': '@jiaminghi/data-view',
axios: 'axios',
echarts: 'echarts',
'element-ui': 'element-ui',
'insert-css': 'insert-css',
jquery: 'jquery',
lodash: 'lodash',
moment: 'moment',
qs: 'qs',
sortablejs: 'sortablejs',
'tiny-sass-compiler': 'tiny-sass-compiler',
'vue-codemirror': 'vue-codemirror',
'vue-contextmenujs': 'vue-contextmenujs',
'vue-draggable-resizable-gorkys': 'vue-draggable-resizable-gorkys',
'vue-json-editor': 'vue-json-editor',
'vue-json-viewer': 'vue-json-viewer',
'vue-quill-editor': 'vue-quill-editor',
'vue-sketch-ruler': 'vue-sketch-ruler',
vuedraggable: 'vuedraggable',
ztree: 'ztree'
},
resolve: {
alias: {
'@': resolve('example'),
packages: resolve('packages')
},
fallback: {
path: false,
fs: false
}
},
plugins: [
new CompressionPlugin({
test: /\.js$|\.html$|\.css$|\.jpg$|\.jpeg$|\.png/, // 需要压缩的文件类型
threshold: 10240, // 归档需要进行压缩的文件大小最小值,10K以上的进行压缩
deleteOriginalAssets: false // 是否删除原文件
}),
new ProvidePlugin({
jQuery: 'jquery',
$: 'jquery',
'window.jQuery': 'jquery'
})
]
},
chainWebpack: config => {
// set svg-sprite-loader
config.module
.rule('svg')
.exclude.add(resolve('packages/assets/images/bigScreenIcon/svg'))
.add(resolve('packages/Svgs/svg'))
.add(resolve('packages/assets/images/dataSourceIcon/svg'))
.add(resolve('packages/assets/images/pageIcon/svg'))
.end()
config.module
.rule('icons')
.test(/\.svg$/)
.include.add(resolve('packages/assets/images/bigScreenIcon/svg'))
.add(resolve('packages/Svgs/svg'))
.add(resolve('packages/assets/images/dataSourceIcon/svg'))
.add(resolve('packages/assets/images/pageIcon/svg'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]'
})
.end()
const imagesRule = config.module.rule('images')
imagesRule.uses.clear()
config.module
.rule('images')
.set('parser', {
dataUrlCondition: {
maxSize: 1024 * 1024
}
})
.end()
// 处理font
config.module
.rule('font')
.test(/\.(ttf|woff|woff2)$/)
.set('parser', {
dataUrlCondition: {
maxSize: 1024 * 1024
}
})
.end()
}
}