Member-only story
Deploy Angular application to Google Cloud Storage (GCP) with GZip compression
After publishing the previous story about how to compress Angular application, and deploy it to Azure Blob Storage, I have been getting many requests/questions asking how to compress and deploy the same to Google Cloud Storage bucket.
The problem statement, background have been covered in previous story. So here I will directly jump to GCP solution. If you haven’t read it, then please do so.
Google Cloud Storage Bucket Setup
Let’s create a bucket to deploy our Angular application. We would like to make this bucket public. To do so, we will have to change the permissions.
- Select the target GCP bucket and go to its details.
- Click on “Permission” tab, and click on “Add”. In the modal box, enter
allUsers
in “New principals” andStorage Object Viewer
in “Role”. - Click on “Save”. This will make your bucket
public
. BE CAREFUL WHAT YOU UPLOAD IN THIS BUCKET. ANYONE CAN VIEW IT.
Build Angular app with — base-href
The important step while building an Angular application is to specify the --base-href
. Because, once deployed, the GCP Bucket prefix name will be required to access the script
, link
and…