How to deploy angular app to production
ng serve
ng serve
is for development purpose. Check docs.
When using ng serve
the compiled output is served from memory, not from disk.
This means that the application being served is not located on disk in the dist folder.
ng build
ng build
--prod is for production purpose. Check docs.
ng build
compiles the application into an output directory.
The build artifacts will be stored in the dist/ directory, inside the root directory of your angular app.
Jus copy the dist folder to any server like IIS or Node Express and your angular app is up and running.
To deploy you app using IIS check this and using Node Express check this.
Generally, I do not use Angular CLI's built in web server for production deployments.
With Angular CLI, you can create a production build using this command
ng build –prod
That will create a dist
folder, which you can upload to any web server of your choosing to deploy an application.
First and foremost, you should build your app for production using
ng build --prod
You'll find a dist
folder in your project folder. This is the Production-ready version of your app.
Now you'd require a server to deploy your app. Install this - https://www.npmjs.com/package/http-server and run using http-server dist/myProject
(replace myProject with your project name)