Deploying an angular app to heroku from github subdirectory

 


1.Check Node and Npm version

2.Create Angular App

3.Run app(ng serve)

4.Add "heroku-postbuild": "ng build --prod" and "start": "node server.js"  in scripts in package.json

5. Add  "engines": {    "node": "local machine version",    "npm": "local machine version"  } in package.json

6.Take devDependencies(@angular/cli,@angular/compiler-cli,typescript) to dependencies  in package.json

7.install express server. npm install express path --save

8.Create server.js file in root directory and put this .

const express = require('express');

const path = require('path');

const app = express();

app.use(express.static('./dist/appname'));

app.get('/*', (req, res) =>

    res.sendFile('index.html', {root: 'dist/appname/'}),

);

app.listen(process.env.PORT || 8080);

9. add "start": "node server.js" in scripts in in package.json

10.init git repo: (git remote add origin <new_repo_url> and commits and push )

11.login to heroko

12.create app 

13.connect to GitHub repo 

14.if necessary ,add buildpacks(https://github.com/timanovsky/subdir-heroku-buildpack)  and nodejs and set PROJECT_PATH=Subdirectory folder name from setting 















15.select branch to Deploy 

Comments

Popular posts from this blog

Provision AWS EC2 Instance and RDS with Terraform, and Deploy Spring Boot App to EC2 Instance via GitHub Action Pipeline

JQuery UI Autocomplete, custom HTML structure for result?

Easy Ui Jquery easyui-textbox change onChange event