-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
57 lines (54 loc) · 1.42 KB
/
webpack.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
'use strict';
const path = require('path');
const webpack = require('webpack');
const config = (module.exports = {
entry: {
js: ['./app/client/index'],
vendor: [
'react',
'react-dom',
'react-redux',
'react-bootstrap-table',
'react-mdl',
],
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader?cacheDirectory',
},
],
},
externals: {
highcharts: 'Highcharts',
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
filename: 'vendor.bundle.js',
}),
new webpack.DefinePlugin({
'process.env.BASE_URL': JSON.stringify(process.env.BASE_URL),
}),
],
output: {
filename: 'app-bundle.js',
publicPath: `${process.env.BASE_URL || ''}/js/`,
path: path.join(__dirname, '/static/js'),
},
});
if (process.env.NODE_ENV === 'production') {
// install polyfills for production
config.entry.vendor.push('babel-polyfill', 'whatwg-fetch');
config.plugins.push(
new webpack.optimize.UglifyJsPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
})
);
}