-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.dll.config.js
59 lines (53 loc) · 1.74 KB
/
webpack.dll.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
const path = require("path");
const webpack = require("webpack");
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const config = require('./package.json');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const curDate = new Date();
const curTime = curDate.getFullYear() + '/' + (curDate.getMonth() + 1) + '/' + curDate.getDate() + ' ' + curDate.getHours() + ':' + curDate.getMinutes() + ':' + curDate.getSeconds();
const bannerTxt = config.name + ' ' + config.version + ' ' + curTime;
const vendorStr = "{{bucket}}";
let vendor = ['vue'];
vendor = vendor.concat(vendorStr.split(','));
let vendordev=['vue/dist/vue.esm.js'];
vendordev =vendordev.concat(vendorStr.split(','));
module.exports = {
//你想要打包的模块数组
entry:{
vendor:vendor,
vendordev:vendordev
},
output:{
path:path.join(__dirname,'/static/'),
filename:'[name].dll.js',
library:'[name]_library'
//vendor.dll.js 中暴露出的全局变量
//主要是给DllPlugin中的name 使用
//故这里需要和webpack.DllPlugin 中的 'name :[name]_libray 保持一致
},
plugins:[
new CleanWebpackPlugin(['static','vendor-manifest.json','vendordev-manifest.json']),
new webpack.DllPlugin({
path:path.join(__dirname,'.','[name]-manifest.json'),
name:'[name]_library',
context:__dirname
}),
new UglifyJsPlugin({
cache:true,
sourceMap:false,
parallel:4,
uglifyOptions: {
ecma:8,
warnings:false,
compress:{
drop_console:true,
},
output:{
comments:false,
beautify:false,
}
}
}),
new webpack.BannerPlugin(bannerTxt)
]
}