-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.dll.babel.js
108 lines (95 loc) · 2.53 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
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
import path from 'path';
import webpack from 'webpack';
import merge from 'webpack-merge';
import ProgressBarWebpackPlugin from 'progress-bar-webpack-plugin';
const isProduction = process.env.NODE_ENV === 'production';
const reactVendors = [
'react',
'react-dom',
'react-router-dom',
'react-redux',
'react-hot-loader',
'redux',
'redux-devtools',
'redux-devtools-dock-monitor',
'redux-devtools-log-monitor',
'redux-logger',
'redux-promise-middleware',
'redux-thunk',
'connected-react-router',
];
const bootstrap = [
'jquery',
'bootstrap',
'reactstrap'
];
const immutableVendors = [
'immutable',
];
const miscVendors = [
'hammerjs',
'lodash',
'prismjs',
'regenerator-runtime',
];
// Base config
let config = {
// The base directory, an absolute path, for resolving entry points and loaders from configuration
context: path.resolve(__dirname),
// Start entry point(s)
entry: {
react: reactVendors,
materialize: bootstrap,
immutable: immutableVendors,
misc: miscVendors,
},
// Affecting the output of the compilation
output: {
// path: the output directory as an absolute path (required)
path: path.resolve(__dirname, 'frontend/dist/dll/'),
// filename: specifies the name of output file on disk (required)
filename: '[name]_dll.js',
// library: name of the generated dll reference
library: '[name]_dll',
},
// A list of used webpack plugins
plugins: [
// Better building progress display
new ProgressBarWebpackPlugin({
clear: false,
}),
// jQuery support
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
'root.jQuery': 'jquery',
}),
// Output manifest json file for each generated dll reference file
new webpack.DllPlugin({
path: path.resolve(__dirname, 'frontend/dist/dll/[name]_manifest.json'),
name: '[name]_dll',
}),
],
};
// Production enviroment
if (isProduction) {
config = merge(config, {
plugins: [
// Minimize javascript files with source map generated
new webpack.optimize.UglifyJsPlugin({
output: { comments: false },
}),
// Define production env which shaved off 75% of the build output size
// http://moduscreate.com/optimizing-react-es6-webpack-production-build
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
],
});
}
// Export const (import/no-mutable-exports)
const constConfig = config;
export default constConfig;