-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.js
43 lines (34 loc) · 916 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
35
36
37
38
39
40
41
42
43
/* eslint strict: 0, no-console: 0 */
'use strict';
const express = require('express');
const path = require('path');
const webpack = require('webpack');
const config = require('./webpack.config.development');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const app = express();
const compiler = webpack(config);
const PORT = 3000;
const wdm = webpackDevMiddleware(compiler, {
publicPath: config.output.publicPath,
noInfo: true,
stats: {
colors: true
}
});
app.use(wdm);
app.use(webpackHotMiddleware(compiler));
const server = app.listen(PORT, 'localhost', err => {
if (err) {
console.log(err);
return;
}
console.log(`Listening at http://localhost:${PORT}`);
});
process.on('SIGTERM', () => {
console.log('Stopping dev server');
wdm.close();
server.close(() => {
process.exit(0);
});
});