-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.hot.reload.js
executable file
·39 lines (32 loc) · 1.03 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
// @flow weak
/* 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(3000, (err) => {
if (err) {
return console.error(err);
}
console.log(
`
=====================================================
-> Server (${chalk.bgBlue('Hot reload')}) 🏃 (running) on ${chalk.green('localhost')}:${chalk.green('3000')}
=====================================================
`
);
});