Approach
The ng build command compiles the Angular app into an output directory named dist/ at the given output path. This command must be executed from within the working directory. The application builder in Angular uses the webpack build tool, with configuration options specified in the workspace configuration file (angular.json) or with a named alternative configuration. A “production” configuration is created by default when you use the CLI to create the project, and you can use that configuration by specifying the –configuration=”production” or the –prod=”true” option.
The –prod flag activates many optimization flags. One of them is –aot for Ahead Of Time compilation. Your component templates are compiled during the build, so TypeScript can detect more issues in your code. You can compile in dev mode but still activate the –aot flag if you want to see this error before building for prod. dist/ Folder The dist folder is the build folder which contains all the files and folders which can be hosted on the server. The dist folder contains the compiled code of your angular application in the format of JavaScript and also the required HTML and CSS files.