forked from equicy/vue-build-optimize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
92 lines (84 loc) · 2.33 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
const webpack = require('webpack')
const SpeedMeasureWebpackPlugin = require('speed-measure-webpack-plugin')
const AddAssetHtmlWebpackPlugin = require('add-asset-html-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
// const Happypack = require('happypack')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const path = require('path')
module.exports = {
parallel: true,
chainWebpack: config => {
config.plugin('vendorDll1')
.use(webpack.DllReferencePlugin, [
{
context: __dirname,
manifest: require('./other_vendor.manifest.json')
}
])
config.plugin('vendorDll2')
.use(webpack.DllReferencePlugin, [
{
context: __dirname,
manifest: require('./vue_vendor.manifest.json')
}
])
config.plugin('speed')
.use(SpeedMeasureWebpackPlugin)
//将dll下的文件自动插入到index.html中
config.plugin('asset')
.use(AddAssetHtmlWebpackPlugin, [
[
{
filepath: path.resolve(__dirname, 'public/dll/vue_vendor.dll.js'),
outputPath: 'dll',
publicPath: '/dll'
},
{
filepath: path.resolve(__dirname, 'public/dll/other_vendor.dll.js'),
outputPath: 'dll',
publicPath: '/dll'
}
]
])
config.plugin('clean')
.use(CleanWebpackPlugin)
// const jsRule = config.module.rule('js');
// jsRule.uses.clear();
// jsRule.use('Happypack/loader?id=babel')
// .loader('Happypack/loader?id=babel')
// .end();
// config.plugin('happypack')
// .use(Happypack, [{
// id:'babel',
// loaders:['babel-loader?cacheDirectory=true']
// }])
// config.module.rule('vue')
// .use('thread-loader')
// .loader('thread-loader')
// .before('vue-loader')
},
configureWebpack: config => {
config.externals = {
jquery: 'jQuery'
},
config.optimization.minimizer = [
new UglifyJsPlugin({
uglifyOptions: {
compress: {
drop_console: true,
},
warnings: false,
parallel: true, //默认并发运行数:os.cpus().length - 1
}
})
]
}
// configureWebpack:{
// externals: {
// jquery: 'jQuery',
// },
// module: {
// noParse: /^(lodash|moment)$/
// }
// }
}