-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
33 lines (24 loc) · 826 Bytes
/
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
const express = require('express')
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const config = require('./webpack.config.js');
const path = require('path');
const compiler = webpack(config);
const bodyParser = require('body-parser');
const app = express();
const port = 8080;
const favicon = require('serve-favicon');
app.use(bodyParser.json());
app.use(express.static(path.join(__dirname, 'data')));
// app.use(express.static('data'));
// line to serve favicon
app.use(favicon(path.join(__dirname, 'favicon.ico')));
app.get('/', (req, res) => {
res.sendFile(path.resolve(__dirname+'/index.html'));
});
app.use(webpackDevMiddleware(compiler, {
publicPath: config.output.publicPath
}));
app.listen(port, () => {
console.log(`listening on port ${port}!`)
});