Let's optimize an Angular application for production.
This repository shows how to apply a number of techniques on a technical demo application. This includes bundling, tree shaking, ahead of time compilation, lazy loading and pre-rendering with universal.
You can build the demo yourself, or check it at: http://mlaval.github.io/optimize-angular-app/
This projects was used for a presentation at angular-up in 2016: slides and video
npm installto prepare your environmentnpm run buildto build all versions of the application (it takes several minutes)npm startto serve the files at http://localhost:8080/
The build task executes a number of independent steps which can be executed separately if needed:
npm run clean: clean all generated filesnpm run public: generate and copy static assetsnpm run devnpm run bundling-appnpm run bundling-fullnpm run treeshaking-rollupnpm run treeshaking-webpacknpm run aot-closurenpm run aot-rollupnpm run aot-systemjsnpm run aot-webpacknpm run laxyloading-closurenpm run lazyloading-systemjsnpm run lazyloading-webpacknpm run prerender
To develop the application itself, here is the workflow:
npm run cleannpm run publicnpm run watch: watch and transpile the application source codenpm startto serve the files at http://localhost:8080/
To run integration tests:
npm run build- Build the closure-compiler cases (see above)
npm test
To generate a performance report:
npm run build- Build the closure-compiler cases (see above)
npm run perf