-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
38 lines (31 loc) · 1007 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
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const config = require('./webpack.config');
const internalIp = require('internal-ip');
const express = require('express');
const webpack = require('webpack');
const path = require('path');
const app = express();
const compiler = webpack(config);
app.use(webpackDevMiddleware(compiler, {
noInfo: true,
publicPath: config.output.publicPath,
silent: false,
stats: { colors: true }
}));
app.use(webpackHotMiddleware(compiler));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, './docs/index.html'));
});
const port = 8080;
const ip = internalIp.v4();
app.listen(port, (err) => {
if (err) {
console.log(err);
return;
}
console.log(' --------------------------------------');
console.log(` Local: http://0.0.0.0:${port}`);
console.log(` External: http://${ip}:${port}`);
console.log(' --------------------------------------');
});