Simple Deployment
For the simple deployment, follow the steps given below:
Step 1: Make a production build, by running the command given below:
ng build --prod
It will create the dist
folder, that contains the production build files.
Step 2: Now you just need to upload the dist
files on to the server.
Step 3: Configure the server to redirect requests for missing files to index.html
. Learn more about server-side redirects below.
AOT
It is Ahead-of-Time (AOT) compiler, which compiles your app at build time. For AOT compilation, include the --aot
option with the commands.
ng build --prod --aot
Further help
To get more help on the angular-cli
use ng --help
or for more details, please visit https://github.com/angular/angular-cli.
Build command for gene
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:
<base href="/">
and set your path as per requirement like:
<base href="/output/">
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.