Skip to content

Commit 753df73

Browse files
committed
Add simple express sever for serving the app
1 parent cfd0ddb commit 753df73

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

Procfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
web: npm install && npm start
1+
web: npm start

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
"license": "MIT",
55
"scripts": {
66
"ng": "ng",
7-
"start": "ng serve",
7+
"start": "node www.js",
88
"build": "ng build",
99
"test": "ng test",
1010
"lint": "ng lint",
11-
"e2e": "ng e2e"
11+
"e2e": "ng e2e",
12+
"postinstall": "ng build"
1213
},
1314
"private": true,
1415
"dependencies": {
@@ -21,6 +22,7 @@
2122
"@angular/platform-browser-dynamic": "^4.0.0",
2223
"@angular/router": "^4.0.0",
2324
"core-js": "^2.4.1",
25+
"express": "4.15.2",
2426
"rxjs": "^5.1.0",
2527
"zone.js": "^0.8.4"
2628
},

src/favicon.ico

-5.3 KB
Binary file not shown.

www.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const express = require('express');
2+
const path = require('path');
3+
const app = express();
4+
// Run the app by serving the static files
5+
// in the dist directory
6+
app.use(express.static(__dirname + '/dist'));
7+
// Start the app by listening on the default
8+
// Heroku port
9+
app.listen(process.env.PORT || 8080);
10+
11+
// For all GET requests, send back index.html
12+
// so that PathLocationStrategy can be used
13+
app.get('/*', function(req, res) {
14+
res.sendFile(path.join(__dirname + '/dist/index.html'));
15+
});

0 commit comments

Comments
 (0)