How to deploy an Angular 7 app to Github Pages

Use npm angular-cli-ghpages package to easily deploy your app to GitHub Pages

Marina Ferreira
Code Sketch

--

Set gh-pages to be the brach to build from in repo settings:

🌹  git checkout -b gh-pages
🌹 git push origin gh-pages
🌹 npm install -g angular-cli-ghpages
🌹 ng build --prod --base-href https://[username].github.io/[repo]/
🌹 ngh --dir=dist/[project-name]

It is only necessary to set the the--base-href flag once, next time you build the project you can simply run:

🌹  ng build --prod

In order to compile images correctly use path as following:

'./assets/images/image.png'

References:

--

--