How to bundle an Angular app for production?

Technology CommunityCategory: AngularHow to bundle an Angular app for production?
VietMX Staff asked 3 years ago

OneTime Setup

  • npm install -g @angular/cli
  • ng new projectFolder creates a new application

Bundling Step

  • ng build --prod (run in command line when directory is projectFolder)
  • flag prod _bundle for production

bundles are generated by default to projectFolder/dist/

Deployment

You can get a preview of your application using the ng serve --prod command that starts a local HTTP server such that the application with production files is accessible using http://localhost:4200.

For a production usage, you have to deploy all the files from the dist folder in the HTTP server of your choice.