-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-webpack-libs.config.js
114 lines (100 loc) · 2.61 KB
/
create-webpack-libs.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
/**
* Created by Devicalin on 2015/11/15.
*/
'use strict';
let webpack = require('webpack');
let path = require('path');
let fs = require('fs');
// let HappyPack = require('happypack');
module.exports = function(DEBUG){
let happyId = DEBUG ? 'libs-debug' : 'libs';
let plugins = [
// new HappyPack({ id: happyId }),
new webpack.DllPlugin({
path: DEBUG ? 'manifest-debug.json' : 'manifest.json',
name: '[name]_lib',
context: __dirname
})
];
if (!DEBUG) {
plugins.push(
new webpack.optimize.UglifyJsPlugin({
output: {
comments: false
},
compress: {
warnings: false
},
sourceMap: false
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
})
);
} else {
plugins.push(
new webpack.LoaderOptionsPlugin({
debug: true
})
);
}
let libs = [
'react',
'react-dom',
'mobx',
'mobx-react',
'react-router-dom',
'fastclick'
];
if(DEBUG) {
libs.push(
// 'why-did-you-update',
'mobx-react-devtools',
'react-addons-perf'
);
}
return {
target: 'web',
entry: {
libs: libs
},
output: {
path: './public/',
filename: DEBUG ? "./js/[name]-debug.js" : "./js/[name]-min.js",
chunkFilename: DEBUG ? "./js/[name]-debug.js" : "./js/[name]-min.js",
publicPath: '',
pathinfo: false,
libraryTarget: 'umd',
library: '[name]_lib'
},
cache: true,
devtool: DEBUG && "eval-source-map",
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
use: [{
loader: 'babel-loader',
options: {
cacheDirectory: true
},
}]
}
]
},
plugins: plugins,
externals: {
},
resolve: {
modules: [
"node_modules"
],
// Allow to omit extensions when requiring these files
extensions: [".js", ".jsx", ".es6", '.json'],
alias: {}
}
};
};