-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (28 loc) · 961 Bytes
/
index.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
// server.js
const bodyParser = require('body-parser');
const express = require('express');
const path = require('path');
const webpack = require('webpack');
const devMiddleware = require('webpack-dev-middleware');
const hotMiddleware = require('webpack-hot-middleware');
const config = require('./webpack.config');
const isDeveloping = process.env.NODE_ENV !== 'production';
const app = express();
if (isDeveloping) {
const compiler = webpack(config);
app
.use(devMiddleware(compiler, { publicPath: config.output.publicPath }))
.use(hotMiddleware(compiler));
}
app
.disable('etag')
.use(bodyParser.urlencoded({ extended: false }))
.use(bodyParser.json())
.use(express.static(path.resolve(__dirname)));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'index.html'));
});
const PORT = process.env.PORT || 3333;
app.listen(PORT, () => {
console.log(`App entryening on port ${PORT}!`); // eslint-disable-line
});