Angular build version

SemVer.

Add 'node' to 'tsconfig.app.json':


{

  "compilerOptions": {

    "types": ["node"]

  }

}

Add 'appVersion' to 'src/environments/environment.prod.ts':


export const environment = {

  production: true,

  appVersion: require('../../package.json').version

};

Add 'appVersion' to 'src/environments/environment.ts':


export const environment = {

  production: false,

  appVersion: require('../../package.json').version + '--dev'

};

Add 'appVersion' attribute for the main 'AppComponent':


import { Component, HostBinding } from '@angular/core';

import { environment } from 'src/environments/environment';



@Component({

  ...

})

export class AppComponent {

  @HostBinding('attr.app-version') appVersionAttr = environment.appVersion;

}

CLI commands to bump up the version via npm:


npm version patch

npm version minor

npm version major

Leave a Comment