Saturday, October 3, 2020

A straight forward way to deploy Angular JS app to Heroku

For the whole story, visit my Medium artcile here: A straight forward way to deploy Angular JS to Heroku
Here's the cheat sheet:
ng new [my-app-name]
cd [my-app-name]
ng build
heroku create [my-app-name]
npm install express --save
vi server.js
  
const express = require('express');
const app = express();
app.use(express.static('./dist/[my-app-name]'));
app.get('/*', function(req, res) { res.sendFile('index.html', {root: 'dist/[my-app-name]'});
});
app.listen(process.env.PORT || 8080);
  
vi package.json
  
//update "start" script
"start": "node server.js"
  
heroku git:remote -a [my-app-name]
git add .
git commit -m "initial commit."
git push heroku master
open https://[my-app-name].herokuapp.com

No comments: