-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.server.dev.js
48 lines (40 loc) · 1.22 KB
/
web.server.dev.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
44
45
46
47
48
/* eslint-disable no-console */
const favicon = require('serve-favicon');
const path = require('path');
const express = require('express');
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const appConfig = require('./webpack.app.config.dev.js');
const PORT = process.env.PORT;
const HOSTNAME = process.env.HOSTNAME;
const app = express();
function mountApp(app, config) {
const compiler = webpack(config);
app.use(webpackDevMiddleware(compiler, {
publicPath: config.output.publicPath,
noInfo: true,
hot: true,
historyApiFallback: true,
stats: {
colors: true,
hash: false,
version: false,
chunks: false,
children: false,
},
}));
app.use(webpackHotMiddleware(compiler, { log: console.log }));
}
app.use(favicon(`${__dirname}/app/web/public/favicon.ico`));
mountApp(app, appConfig);
app.use('/', (req, res) => {
res.sendFile(path.join(__dirname, '/app/web/public', 'index.html'));
});
app.listen(PORT, HOSTNAME, (err) => {
if (err) {
console.log(`💔 ${err}`);
return;
}
console.log(`❤️ App is now running on http://${HOSTNAME}:${PORT}`);
});