Deploy angular apps in production

The following two tabs change content below.
Prasad Kharkar is a java enthusiast and always keen to explore and learn java technologies. He is SCJP,OCPWCD, OCEJPAD and aspires to be java architect.

Latest posts by Prasad Kharkar (see all)

In last article we saw how to deploy angular apps in tomcat server. However, we did it for development mode and its not optimised way. We will learn how to deploy angular apps in production.

 

Deploy Angular Apps In Production:

We can simply run below command to build the app.

  • ng invokes angular
  • build prepares the build
  • –prod : specifies production mode, which means it can do ahead of time compilation
  • –build-optimizer creates smaller bundles of files.
  • –base-href=/angular/  This creates a base reference for built javascript files.

After build is successful, it will create a dist folder from which we can deploy angular app in production.

Copy all files in dist folder and copy to /angular/ folder in whatever production server you are using.

For example, we we are using tomcat as production server, copy all files in /webapps/angular/ and fire up the server. Visit localhost:8080/angular/ 

You will be able to view angular app running in browser.

I hope this article helped deploy angular apps in production.

 

Share Button

Prasad Kharkar

Prasad Kharkar is a java enthusiast and always keen to explore and learn java technologies. He is SCJP,OCPWCD, OCEJPAD and aspires to be java architect.

Leave a Reply

Your email address will not be published. Required fields are marked *