-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathdev-server.js
51 lines (47 loc) · 1.26 KB
/
dev-server.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
const webpack = require('webpack')
const WebpackDevServer = require('webpack-dev-server')
const path = require('path')
const baseConfig = require('./webpack.config.js')
const host = '127.0.0.1'
const port = 3000
const addr = `http://${host}:${port}`
const config = Object.assign({}, baseConfig, {
devtool: 'inline-source-map',
entry: [
`webpack-dev-server/client?${addr}`,
'webpack/hot/only-dev-server',
...baseConfig.entry
],
plugins: [
new webpack.LoaderOptionsPlugin({
debug: true
}),
// make the store behave like production (less chatty) if desired
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new webpack.HotModuleReplacementPlugin()
],
module: {
rules: [
{
test: /\.js?$/,
exclude: /node_modules/,
use: [ 'react-hot-loader' ],
include: [ path.join(__dirname, 'src') ]
},
...baseConfig.module.rules
]
}
})
const server = new WebpackDevServer(webpack(config), {
contentBase: 'src/static/',
stats: config.stats,
publicPath: config.output.publicPath,
hot: false,
historyApiFallback: true
})
server.listen(port, host, (err) => {
return err ? console.error(err)
: console.log(`Listening on: ${addr}`)
})