-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.dll.babel.js
73 lines (63 loc) · 1.93 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
import path from 'path';
import webpack from 'webpack';
import BundleTracker from 'webpack-bundle-tracker';
const isProduction = process.env.NODE_ENV === 'production';
const reactVendors = [
'react',
'react-dom',
'react-router',
'react-redux',
'redux',
];
// 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,
},
// 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: [
// 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',
}),
// Output webpack compiled bundle state json file for django backend
new BundleTracker({ filename: './webpack-stats.dll.json' }),
],
};
// Production enviroment
if (isProduction) {
config = {
...config,
plugins: [
// Extend base config
...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;