-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.hot.reload.js
executable file
·41 lines (34 loc) · 1.06 KB
/
server.hot.reload.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
// @flow
// @ts-check
// typescript
/* eslint no-console:0 */
/* eslint consistent-return:0 */
const path = require('path');
const webpack = require('webpack');
const express = require('express');
const devMiddleware = require('webpack-dev-middleware');
const hotMiddleware = require('webpack-hot-middleware');
const config = require('./webpack.hot.reload.config');
const chalk = require('chalk');
const app = express();
const compiler = webpack(config);
app.use(devMiddleware(compiler, {
publicPath: config.output.publicPath,
historyApiFallback: true
}));
app.use(hotMiddleware(compiler));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});
app.listen(3001, (err) => {
if (err) {
return console.error(err);
}
console.log(
`
=====================================================
-> Ratings Server (${chalk.bgBlue('Hot reload')}) 🏃 (running) on ${chalk.green('localhost')}:${chalk.green('3001')}
=====================================================
`
);
});