-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
executable file
·72 lines (63 loc) · 1.47 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
69
70
71
// this object is the common configuration for webpack whether it is
// used in production or development
const webpack = require('webpack');
const commonConfig = {
entry: './app/index.js',
output: {
filename: 'bundle.js',
path: './server/public/'
},
resolve: {
extensions: ['.jsx', '.js', '']
},
module: {
loaders: [
{
test: /\.jsx?/,
exclude: /node_modules/,
loader: 'babel'
}
]
}
}
// this is the dev setup we want our webpack to have
const devConfig = {
devtool: 'source-maps',
devServer: {
inline: true,
historyApiFallback: true,
contentBase: './server/public/'
}
}
// this would be production settings we would want webpack to use
const prodConfig = {
plugins: [
new webpack.optimize.UglifyJsPlugin({
beautify: false,
comments: false,
compress: {
warnings: false,
// drop_console: true
},
mangle: {
except: ['$'],
screw_ie8: true,
keep_fnames: true
}
})
]
}
const config = {};
// this is how we can see if webpack should be used in production mode
// or if it should be used in a developer mode
// if TARGET is 'build' -> production mode
// if TARGET is 'dev' -> development mode
const TARGET = process.env.npm_lifecycle_event;
switch (TARGET) {
case 'dev' :
Object.assign(config, commonConfig, devConfig);
break;
default :
Object.assign(config, commonConfig, prodConfig);
}
module.exports = config;