-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.dll.babel.js
66 lines (62 loc) · 1.59 KB
/
webpack.config.dll.babel.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
import path from 'path'
import webpack from 'webpack'
import WebpackMd5Hash from 'webpack-md5-hash'
import AssetsPlugin from 'assets-webpack-plugin'
const distPath = path.resolve(__dirname, 'dist')
const assetsPath = path.resolve(__dirname, 'assets')
export default {
entry: {
vendor: [
'react',
'react-dom',
'react-router',
'react-router-dom',
'redux',
'redux-thunk',
'react-redux',
'react-router-redux'
]
},
output: {
path: distPath,
filename: '[name].[chunkhash].dll.js',
library: '[name]_lib'
},
plugins: [
// 将打包环境定为生产环境
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
// DllPlugin 生成公共模块
new webpack.DllPlugin({
/*
* 定义 manifest 文件生成的位置
* [name] 的部分由 entry 的名字替换
*/
path: path.resolve(assetsPath, '[name]-manifest.json'),
/*
* name
* dll bundle 输出到哪个全局变更上
* 和 output.library 一样即可
*/
name: '[name]_lib',
context: __dirname
}),
// 记录output中带有hash的名字,生成 webpack-assets.json 的文件
new AssetsPlugin({
path: path.resolve(assetsPath)
}),
// 压缩
new webpack.optimize.UglifyJsPlugin({
compress: {
// supresses warnings, usually from module minification
warnings: false
},
comments: false
}),
// 真正的文件 md5 hash
new WebpackMd5Hash()
]
}