-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack-config.es6.js
81 lines (73 loc) · 2.02 KB
/
webpack-config.es6.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
import path from 'path';
import webpack from 'webpack';
export default function() {
var config = {
cache: true,
entry: {
//'webpack-dev-server': 'webpack-dev-server/client?http://0.0.0.0:8080', // WebpackDevServer host and port
//'webpack-hot': 'webpack/hot/only-dev-server',
app: './src/js/application/bootstrap.js',
vendors: [
'react',
'lodash',
'underscore'
]
},
output: {
filename: '[name].js',
path: path.join(__dirname, 'public'),
publicPath: 'public',
chunkFilename: 'app.js',
sourceMapFilename: '[file].map'
},
plugins: [
//new webpack.HotModuleReplacementPlugin(),
new webpack.optimize.CommonsChunkPlugin(
'vendors',
'vendors.js'
)
],
'module': {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader?experimental'
},
{
test: /\.jsx$/,
loaders: [
//'react-hot',
'babel-loader?experimental'
],
exclude: /node_modules/
}
],
noParse: []
},
resolve: {
alias: {
underscore: 'lodash'
}
}
};
if (process.env.NODE_ENV === 'production') {
console.log('webpack: production mode');
new webpack.DefinePlugin({
'process.env.NODE_ENV': 'production'
});
config.plugins.push(new webpack.optimize.UglifyJsPlugin());
//config.plugins.push(new webpack.optimize.DedupePlugin());
config.resolve.alias.moment = 'moment/min/moment.min';
config.module.noParse.push(/moment\.min\.js$/);
config.resolve.alias.react = 'react/dist/react-with-addons.min';
config.module.noParse.push(/react-with-addons\.min\.js$/);
} else {
// rebuild each time:
config.resolve.alias.react = 'react/addons';
//config.resolve.alias.react = 'react/dist/react-with-addons';
//config.module.noParse.push(/react-with-addons\.js$/);
config.devtool = 'eval';
}
return config;
};