-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (24 loc) · 884 Bytes
/
app.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
import express from 'express';
import webpack from 'webpack';
import bodyParser from 'body-parser';
import webpackDevMiddleware from 'webpack-dev-middleware';
import logger from 'morgan';
import path from 'path';
import routes from './server/routes/router';
import config from './webpack.config.dev';
const app = express();
const compiler = webpack(config);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
routes(app);
app.use((webpackDevMiddleware)(compiler));
app.use(require('webpack-hot-middleware')(compiler));
app.use(express.static(path.join(__dirname, './client/src/public')));
app.use(logger('dev'));
routes(app);
app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname, './client/src/index.html'));
});
const port = process.env.PORT || 8000;
app.listen(port, () => console.log(`connected on ${port}`));
export default app;