ng serve works for serving our application for development purposes. What about for production? If we look into our package.json file, we can see that there are scripts we can use:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
The build script uses the Angular CLI's ng build with the --prod flag. Let's try that now. We can do it one of two ways:
# using the npm scripts
npm run build
# using the cli directly
ng build --prod
This time we are given four files instead of the five. The --prod flag tells Angular to make our application much smaller in size.