Thursday, November 12, 2020

Deploying Angular Apps to Github Pages

Deploying Angular Apps to Github Pages

You need to have Node.js, NPM and Angular CLI  installed, you also need to generate a new Angular  project using Angular CLI or you can also apply this to an existing project that you want to deploy to Github Pages.

Deploying Angular Apps to Github Pages

Next you also need to install a package which makes the process of deploying to Github pages easy.

$ npm install -g angular-cli-ghpages

Building the Angular Application

The next step is to build your web application for production and with the base href location set to your Github Page URL.

$ ng build --prod --base-href "https://<YOUR_GITHUB_USER-NAME>.github.io/<YOUR_REPO_NAME>/"

Deploying to Github Pages

Now you are ready to deploy your web app to Github pages. Thanks to angular-cli-ghpages this is a one command process so just run:

$ ngh

You web app will be depoyed to https://username.github.io/app-name/.

No comments:

Post a Comment