Search code examples
angularangular8vercel

Deploy a production build of an Angular app with Zeit Now


I am using zeit now to deploy an Angular app. I followed this tutorial.

I created the App using the Angular CLI. I developed it locally by using the command ng serve, and I deployed it by running now. Just as in the tutorial. However, the deployed code does not seem to be minified. If I look in the network tab of developer console, and read the javascript, it does not look minified, it looks just as I wrote it. For reference, my website can be found here https://peacefulprogramming.xyz/

My Questions

1) Does the now command make a production build of my app (equivalent to ng build --prod)?

2) If not, how can I get it to make a production build?


Solution

  • You can deploy your application on zeit by using @zeit/ng-deploy package. After angular cli 8.3.0 is released this will also support the ng deploy command. ng deploy command is currently available in 8.3.0_RC0

    Follow below steps :

    Add @zeit/ng-deploy to your project

    ng add @zeit/ng-deploy You will be prompt to log in to Now account

    Deploy your project to Now

    ng run [project_name]:deploy

    This will create production build and then deploy then on zeit in single command

    After deploying your application you will see output similar to the following:

    Your application is deployed at https://[project-name]-1234.now.sh