-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
39 lines (32 loc) · 1.02 KB
/
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
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);
const middleware = webpackDevMiddleware(compiler, {
noInfo: true,
publicPath: config.output.publicPath,
silent: false,
stats: { color: true }
});
app.use(middleware);
app.use(webpackHotMiddleware(compiler));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, './src/www/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(' --------------------------------------');
});