Zanex - Angular Admin & Dashboard Template

Deployment

When you are ready to deploy your Angular Application to a remote server, you have various options for deployment.

Basic deployment to a remote server

For the simplest deployment, create a production build and copy the output directory to a web server.

  1. Start with the production build:
  2. ng build
  3. Copy everything within the output folder (dist/project-name/ by default) to a folder on the server
  4. Configuration the server to redirects requests for missing files to index.html.
  5. For Example, if the index.html is on the server at /my/app.index.html, set the base href to <base href="/my/app/"> like this.
If you're serving the app out of a subfolder, edit a version of inddex.html to set the base href appropriately. For Example, if the URL to index.html is www.abc.com/my/app/index.html, set the base href to
<base href="/my/app/">

You can also set the base href right in the ng build command.
ng build --base-href="/my/app/"
This is the simplest production-ready deployment of your application. For more detailes information, visit this official Angular Documentation Website.

Ahead-of-Time (AOT) compilation

An Angular Application consists mainly of components and their HTML templates. Because the components and templates provided by Angular cannot be understood by the browser directly, Angular applications require a compilation process before they can run in a browser.

The Angular AOT compiler converts your Angular HTML and Typescript code into efficient JavaScript code during the build phase before the browser downloads and runs that code. Compiling your application during the build process provides a faster rendering in the browser.

Choosing a compiler

Angular offers two ways to compile your application:

  1. Just-in-Time (JIT), which compiles your app in the browserat runtime. This was the default until Angular 8.
  2. Ahead-of-Time (AOT), which compiles your app and libraries at build time. This is the default since Angular 9.
Ahead-of-time (AOT) vs just-in-time (JIT)
There is actually only one Angular compiler. The difference between AOT and JIT is a matter of timing and tooling. With AOT, the compiler runs once at build time using one set of libraries; with JIT it runs every time for every user at runtime using a different set of libraries. To use JIT build, run this command line to build.
ng build --aot