We use the following command to build a production build. It will reduce the build size by optimizing the code at build time.
ng build --prod --aot --build-optimizer
Building for a Relative Path
If you want to make your production build in different folder or sub directory. Like, if you want that the template run on the test.com/output rather then test.com then you need to follow the steps given below:
Step 1: Open the src->index.html file & search for the base tag:
and set your path as per requirement like:
After that you need to create a new sub folder with the name output and upload all the files in this folder.
You need a .htaccess file to upload the build to server. Make sure you have included this file in your folder that you are going to upload on the server.