forked from AugurProject/augur-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
51 lines (42 loc) · 1.12 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const express = require('express');
const helmet = require('helmet');
const http = require('http');
const https = require('https');
const fs = require('fs');
const app = express();
if (process.env.NODE_ENV === 'development') {
const webpack = require('webpack');
const devMiddleware = require('webpack-dev-middleware');
const hotMiddleware = require('webpack-hot-middleware');
const config = require('./webpack.config');
const compiler = webpack(config);
// Hot Module Reload
app.use(devMiddleware(compiler, {
publicPath: config.output.publicPath,
stats: {
colors: true
}
}));
app.use(hotMiddleware(compiler));
} else {
// Static Path
app.use(express.static('build'));
}
app.listen = function () {
let server = null;
if (process.env.USE_SSL === 'true') {
const key = fs.readFileSync('augur-local.key');
const cert = fs.readFileSync('augur-local.crt');
server = https.createServer(
{
key,
cert
},
this
)
} else {
server = http.createServer(this)
}
return server.listen.apply(server, arguments);
}
app.listen(process.env.PORT || 8080);