-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
51 lines (47 loc) · 1.09 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
import webpack from 'webpack';
let config = {
devtool: 'source-map',
target: 'web',
entry: {
simple: ['./examples/simple/index.js']
},
output: {
path: __dirname,
filename: 'examples/[name]/bundle.js',
publicPath: '/'
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['babel-loader']
}]
},
resolve: {
extensions: ['', '.js', '.jsx']
},
plugins: []
};
if(process.env.HOT){
config = {
...config,
devtool: 'eval-source-map',
entry: Object.keys(config.entry).reduce((o, key) => ({...o, [key]: [
'webpack-dev-server/client?http://localhost:3000', // WebpackDevServer host and port
'webpack/hot/only-dev-server'
].concat(config.entry[key])}), {}),
module: {...config.module,
loaders: [{
...config.module.loaders[0],
loaders: [
'react-hot'
].concat(config.module.loaders[0].loaders)
}]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
].concat(config.plugins)
};
}
module.exports = config;