This is part three of a three part series on deploying Angular CLI applications to Github Pages.
In the angular-cli.json
file, modify the assets
object to look like the following:
"assets": [
"assets",
"favicon.ico",
"404.html",
"CNAME"
]
/dist
directory of the project when it builds. Angular CLI deletes all unknown files from the /dist
directory each time it builds.The fourth file that’s copied is the CNAME file. This file is used to tell Github Pages the custom domain from which you want the application to be served. Without copying this file to the distribution directory, you would have to go into the settings section of your Github repository to configure a custom domain each time you deploy.
Create a CNAME
file (no file extension) in the /src
directory of the application. The contents of the CNAME file should contain the custom domain e.g. dcvolunteer.com.
If you haven’t already done so, you’ll need to configure your DNS server with a CNAME entry that points to the Github Pages URL. To configure a domain hosted on Hover’s DNS server, do the following:
@
for the Hostname, A
for the Record Type, and 64.98.145.30
for the value.www
for the Hostname, A
for the Record Type, and 64.98.145.30
for the value.You’re now ready to deploy your application to Github Pages by running the npm run deploy
command we configured in part one. You can find a completed example project on Github).