forked from qdouble/angular-webpack-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprodserver.js
More file actions
29 lines (22 loc) · 743 Bytes
/
prodserver.js
File metadata and controls
29 lines (22 loc) · 743 Bytes
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
"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();
const ROOT = path.join(path.resolve(__dirname, '..'));
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}`);
});