Deployment - Build Process Documentation 🚀

This section covers the build process for the Angular-based frontend application. The application uses the Angular CLI to manage the build and deployment pipelines. Below is a detailed explanation of the steps and configurations involved in building the application for production.


Key Configuration Details 📋

The build process is configured in the angular.json file, where essential settings for production builds are defined. Here's a breakdown of the relevant configurations:

Setting Description
outputPath Specifies the directory where the build files are generated. Default: dist/volley-app.
index The entry HTML file for the application. Default: src/index.html.
main The main TypeScript file to bootstrap the application. Default: src/main.ts.
polyfills Polyfills for browser compatibility. Default: src/polyfills.ts.
tsConfig TypeScript configuration file for the app. Default: tsconfig.app.json.
assets List of static assets to include in the build. Includes src/favicon.ico and src/assets.
styles Global stylesheets. Includes SCSS files and third-party libraries like ngx-toastr.
aot Enables Ahead-of-Time (AOT) compilation for faster rendering. Default: true.
optimization Minifies and optimizes the build for better performance. Enabled in production mode.
sourceMap Controls source map generation. Disabled in production for smaller build sizes.
budgets Sets warnings or errors if the build exceeds specified size limits.

Build Process Steps 🛠️

Follow these steps to build the application for deployment:

Step 1: Install Dependencies

Ensure that all required dependencies are installed:

npm install

Step 2: Run the Build Command

Use the Angular CLI to build the application for production:

npm run build

This command internally uses:

ng build --prod

Step 3: Post-Build Operations

After the build, a _redirects file is added to the dist/volley-app directory for deployment compatibility:

echo '/*    /index.html   200' > dist/volley-app/_redirects

Production-Specific Configurations ⚙️

In the angular.json file, the production configuration is defined as follows:

"configurations": {
  "production": {
    "fileReplacements": [
      {
        "replace": "src/environments/environment.ts",
        "with": "src/environments/environment.prod.ts"
      }
    ],
    "optimization": true,
    "outputHashing": "all",
    "sourceMap": false,
    "extractCss": true,
    "namedChunks": false,
    "extractLicenses": true,
    "vendorChunk": false,
    "buildOptimizer": true,
    "budgets": [
      {
        "type": "initial",
        "maximumWarning": "2mb",
        "maximumError": "5mb"
      },
      {
        "type": "anyComponentStyle",
        "maximumWarning": "6kb",
        "maximumError": "10kb"
      }
    ]
  }
}

Key Highlights:

  • File Replacements: The environment.ts file is replaced with environment.prod.ts for production-specific settings.
  • Optimization: Enabled for code minification and tree-shaking.
  • Build Optimizer: Improves the tree-shaking process for Angular modules.
  • Output Hashing: Adds hashes to filenames for cache-busting.

Deployment Notes 📝

  1. Output Directory: The production-ready files are located in the dist/volley-app directory after the build.
  2. Static Assets: Ensure that all static files (e.g., images, fonts) are included in the assets folder.
  3. Browser Compatibility: The .browserslistrc file ensures compatibility with modern browsers:
    last 1 Chrome version
    last 1 Firefox version
    last 2 Edge major versions
    last 2 Safari major versions
    last 2 iOS major versions
    Firefox ESR
    not IE 9-10
    not IE 11
    

Example Build Command Output 🖥️

√ Browser application bundle generation complete.
√ Copying assets complete.
√ Index html generation complete.

Initial Chunk Files | Names         |  Raw Size | Estimated Transfer Size
main.js             | main          |  500.12 kB | 122.56 kB
styles.css          | styles        |   12.34 kB |   3.45 kB
runtime.js          | runtime       |    1.50 kB |   0.45 kB

Build at: 2023-10-16T10:00:00Z

This documentation ensures a smooth deployment process for the Angular-based frontend application. 🚀