-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.js
67 lines (60 loc) · 2.11 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
58
59
60
61
62
63
64
65
66
67
var webpack = require('webpack');
var path = require('path');
var projectRoot = process.env.PWD; // Absolute path to the project root
var resolveRoot = path.join(projectRoot, 'node_modules'); // project root/node_modules
var publicPath = './build/public';
var envPlugin = new webpack.DefinePlugin({
__DEV__: JSON.stringify(JSON.parse(process.env.DEVELOP || 'true')),
__PROD__: JSON.stringify(JSON.parse(process.env.PRODUCTION || 'true')),
__CLIENT__: true,
__SERVER__: false
});
var commonsPlugin = new webpack.optimize.CommonsChunkPlugin('vendors', 'vendor.js');
var env = new webpack.DefinePlugin({'process.env.NODE_ENV': JSON.stringify('production')});
var plugins = [commonsPlugin];
if(process.env.NODE_ENV == 'production'){
plugins.push(new webpack.optimize.OccurenceOrderPlugin());
plugins.push(new webpack.optimize.DedupePlugin());
plugins.push(new webpack.optimize.UglifyJsPlugin({
compressor: { warnings: false }
}));
plugins.push(env);
}
module.exports = {
entry: {
app: path.resolve(__dirname, 'client/scripts/client.js'),
vendors: ['react', 'react-router', 'superagent', 'redux-thunk', 'history', 'lodash', 'scroll-behavior', 'classnames', 'normalizr',
'redux', 'bluebird', 'autobind-decorator', 'react-router-redux', 'react-bootstrap', 'react-router-bootstrap', 'react-helmet']
},
//devtool: 'source-map',
output: {
filename: '[name].js',
chunkFilename: '[id].chunk.js',
path: publicPath,
publicPath: '/static/'
},
module: {
loaders: [
{
test: /\.js$/,
exclude: [resolveRoot],
loader: 'babel-loader',
query: {
presets: ['es2015', "stage-1", 'react'],
plugins: ["transform-decorators-legacy"]
}
}
]
},
resolve: {
root: [
resolveRoot,
path.join(__dirname, 'node_modules')
],
extensions: ['', '.js', '.json']
},
plugins: plugins,
modulesDirectories: [
'node_modules'
]
};