简体   繁体   中英

Deploy Angular in Github Pages

I followed the docs in https://angular.io/guide/deployment and use: ng build --prod --output-path docs --base-href /<project_name>/ to build Angular project but I can not find "gh-pages branch" option in setting/source.

Setup:

1.You have an angular project.

2.Install angular-cli-ghpages package from npm like this
'npm install -g angular-cli-ghpages'

3. You can setup npm script like this or run directly in terminal:
"build-and-deploy-gh-pages": "ng build --prod --base-href ./ && npx ngh --dir dist/[reponame]"

Where ./ can be replaced with:
'https://[username].github.io/[reponame]/'

As a matter of fact, in above link you’ll find your github-page.
You’ll be asked for your github username and password to deploy to gihub pages.

This script will create gh-pages branch automatically and setup your repo for publishing online.

 Next step would be to to run this script as:  'npm run build-and-deploy-gh-pages

I've wrote an article in Medium about deploying angular on github pages.

Please have a look here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM