-
Notifications
You must be signed in to change notification settings - Fork 23
/
server.js
43 lines (34 loc) · 1.03 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
40
41
42
43
/* eslint import/no-commonjs: 0 */
/**
* Http server for serving the frontend files
*/
const path = require('path');
const express = require('express');
const webpack = require('webpack');
const config = require('config');
const webpackConfig = require('./webpack.config');
const app = express();
app.use(require('connect-history-api-fallback')());
const compiler = webpack(webpackConfig);
if (process.env.NODE_ENV === 'development') {
app.use(require('webpack-dev-middleware')(compiler, {
publicPath: '/',
contentBase: path.join(__dirname, 'src'),
hot: true,
quiet: false,
noInfo: false,
lazy: false,
stats: {
chunks: false,
chunkModules: false,
colors: true,
},
}));
app.use(require('webpack-hot-middleware')(compiler));
app.use(express.static(path.join(__dirname, 'src/static')));
} else {
app.use(express.static(path.join(__dirname, 'dist')));
}
const port = config.PORT;
app.listen(port);
console.log(`Server is now running on port: ${port}.`); // eslint-disable-line no-console