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 build --prod --build-optimizer --base-href=/angular/
- 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.
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.