-
Notifications
You must be signed in to change notification settings - Fork 0
/
prodserver.js
30 lines (23 loc) · 693 Bytes
/
prodserver.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
"use strict";
const compression = require('compression')
const express = require('express'),
path = require('path');
const E2E_PORT = require('./constants').E2E_PORT;
const HOST = require('./constants').HOST;
const PROD_PORT = require('./constants').PROD_PORT;
const app = express();
app.use(compression());
app.use(express.static('dist'));
const renderIndex = (req, res) => {
res.sendFile(path.resolve(__dirname, 'dist/index.html'));
}
app.get('/*', renderIndex);
let e2e;
const ENV = process.env.npm_lifecycle_event;
if (ENV === 'e2e:server') {
e2e = E2E_PORT
};
const PORT = e2e || PROD_PORT;
app.listen(PORT, () => {
console.log(`Listening on: http://${HOST}:${PORT}`);
});