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
username
andapiUrl
properties 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\browser
folder. - Navigate to the
dist\gh-portfolio\browser
folder and you should see two HTML files,index.html
and theindex.original.html
file. - Open...