-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
27 lines (22 loc) · 881 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
const path = require('path');
const express = require('express');
const app = express();
const PORT = process.env.PORT || 8086;
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const webpack = require('webpack');
const config = require('./webpack.config');
const compiler = webpack(config);
app.use(webpackDevMiddleware(compiler, {noInfo: true, publicPath: config.output.publicPath}));
app.use(webpackHotMiddleware(compiler));
app.use(express.static(path.join(__dirname, 'dist')));
app.get('/', function (request, response) {
response.sendFile(__dirname + '/dist/index.html')
});
app.listen(PORT, function (error) {
if (error) {
console.error(error);
} else {
console.info("==> Listening on port %s. Visit http://localhost:%s/ in your browser.", PORT, PORT);
}
});