-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
50 lines (47 loc) · 951 Bytes
/
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
var path = require('path'),
webpack = require('webpack'),
merge = require('webpack-merge');
const TARGET = process.env.npm_lifecycle_event;
const PATHS = {
src: path.join(__dirname, 'src'),
dest: path.join(__dirname, 'dist')
}
const common = {
entry: PATHS.src + '/main',
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [
{
test: /\.jsx$/,
include: PATHS.src,
loader: 'babel'
}
]
}
}
if(TARGET === 'start' || !TARGET) {
module.exports = merge(common, {
devServer: {
contentBase: PATHS.src,
port: 8000,
historyApiFallback: true,
hot: true,
inline: true,
progress: true,
stats: 'errors-only'
},
plugins: [
new webpack.HotModuleReplacementPlugin()
]
});
}
if(TARGET === 'build') {
module.exports = merge(common, {
output: {
path: PATHS.dest,
filename: 'bundle.js'
}
});
}