angularwebpacksystemjsangular-cli

How to bundle an Angular app for production


What is the best method to bundle Angular (version 2, 4, 6, ...) for production on a live web server.

Please include the Angular version within answers so we can track better when it moves to later releases.


Solution

  • 2 to 17 (TypeScript) with Angular CLI

    OneTime Setup

    Bundling Step

    bundles are generated by default to projectFolder/dist(/$projectFolder{/,/browser} for v6+)

    Output

    Sizes with Angular 17.0.9 and option CSS without pre-rendering

    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. This is not safe to use for production usage.

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