-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
38 lines (24 loc) · 767 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
38
const express = require('express');
const path = require('path');
const port = process.env.PORT || 8080;
const app = express();
const isDevelopment = process.argv.indexOf('--development') !== -1;
if (isDevelopment) {
const webpack = require('webpack');
const webpackConfig = require('./webpack.config');
const compiler = webpack(webpackConfig);
app.use(require('webpack-dev-middleware')(compiler, {
hot: true,
stats: {
colors: true
}
}));
app.use(require('webpack-hot-middleware')(compiler));
} else {
app.use(express.static(__dirname + '/public'));
}
app.get('*', function (request, response) {
response.sendFile(__dirname + '/public/index.html');
});
app.listen(port);
console.log(`server started on port: ${port}`);