Prerendering content during build
The package.json file of our Angular CLI workspace contains the prerender npm script that we can use to improve the first loading of our application. The script runs the prerender command from the architect section of the angular.json configuration file and prerenders the content of our application during build time. Let's see the effect that prerendering will have on our GitHub portfolio application:
- Execute the following npm command to generate a prerendered version of the application:
npm run prerender
Important note
The
usernameandapiUrlproperties in the environment production file should be set correctly. Otherwise, the command will output errors in the terminal window of VSCode.The preceding command will output a production bundle of the application into the
dist\gh-portfolio\browserfolder. - Navigate to the
dist\gh-portfolio\browserfolder and you should see two HTML files,index.htmland theindex.original.htmlfile. - Open...