forked from buildog/BarterDEX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
34 lines (25 loc) · 863 Bytes
/
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
/* Developement server */
/* eslint no-console: 0 */
import express from 'express'
import webpack from 'webpack'
import webpackDevMiddleware from 'webpack-dev-middleware'
import webpackHotMiddleware from 'webpack-hot-middleware'
import config from './config/webpack.config.dev'
const app = express()
const compiler = webpack(config)
const PORT = process.env.PORT || 3000
const devMiddleware = webpackDevMiddleware(compiler, {
publicPath: config.output.publicPath,
stats: { colors: true }
})
app.use(devMiddleware)
app.use(webpackHotMiddleware(compiler))
const server = app.listen(PORT, 'localhost', err => {
if (err) return console.error(err)
console.log(`Listening at http://localhost:${PORT}`)
});
process.on('SIGTERM', () => {
console.log('Stopping dev server')
devMiddleware.close()
server.close(() => process.exit(0))
})