Types of Compilation in Angular
Angular has two types of compilation.
1. AoT ------ compiles app at build time on the server
2. JIT ------- compiles app in browser at runtime
How can you achieve this in build?
ng build // build only ( JIT compiler is executed default with ng build )
*** ng build // automatically run JIT compilation for build only
*** ng serve // automatically run JIT compilation for build and serve locally.
*** ng serve --prod // automatically run AoT compilation
*** Production mode has configured within angular.json file with Ahead of Time compilation.
*************** Forcefully AoT Compilation ***************************
we need to include the --aot option with the ng build or ng serve command.
ng build --aot // develop build with ahead of time compilation forcefully
ng serve --aot // develop build and serve locally with ahead of time compilation forcefully
************************ AoT Benefits *****************************************
AoT helpful to reduce bundle size for faster rendering.
ByDefault Angular used Client Side Rendering,
We can use Server Side Rendering by using Angular Universal.
ng add @nguniversal/express-engine
npm run dev:ssr
Nice
ReplyDeletethanks a lot
Delete