-
Notifications
You must be signed in to change notification settings - Fork 114
/
webpack.config.js
68 lines (62 loc) · 1.99 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
68
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var pkg = require('./package.json');
// bundle dependencies in separate vendor bundle
var vendorPackages = Object.keys(pkg.dependencies).filter(function (el) {
return el.indexOf('font') === -1; // exclude font packages from vendor bundle
});
/*
* Default webpack configuration for development
*/
var config = {
devtool: 'eval-source-map',
cache: true,
entry: {
main: path.join(__dirname, "app", "App.js"),
vendor: vendorPackages
},
output: {
path: path.join(__dirname, "wwwroot", "js"), //Note: For ASP.NET Core we need to put the output in wwwroot/js
//in production mode make files have a .min.js ending - stops gulp's min:js concating them
filename: process.env.NODE_ENV === 'production' ? '[name].min.js' : '[name].js',
sourceMapFilename: '[file].map'
},
resolve: {
modulesDirectories: ['node_modules']
},
plugins: [
new webpack.OldWatchingPlugin(), //needed to make watch work. see http://stackoverflow.com/a/29292578/1434764
new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.js")
],
resolveLoader: {
'fallback': path.join(__dirname, 'node_modules')
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015','react']
}
}]
}
}
/*
* If bundling for production, optimize output
*/
if (process.env.NODE_ENV === 'production') {
config.devtool = false;
config.plugins = [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
comments: false,
compress: { warnings: false}
}),
new webpack.DefinePlugin({
'process.env': {NODE_ENV: JSON.stringify('production')}
})
];
};
module.exports = config;