Let’s say you want to add the current git commit hash to your angular UI (I’m currently using angular 6) so it will be easier later to debug which version you deployed — such could be achieved easily by using the git-describe lib as follows:

Install git-describe as a dev dependency On your root project create a grab-git-info.js

The output of the grab-git-info.js script will be the ‘git-version.json’ file under /src/ which will contain all the git info needed by our app.

In order to be able to import the json file (or any other json file) we need to add a definition file declaring of the added module so that the Typescript compiler will recognize it.

3. Under your /src create typings.d.ts file (read more about typings.d.ts here: https://angular.io/guide/typescript-configuration#typescript-typings)

From this point on you can import any json file located under /src as a module!

import gitInfo from '../../../git-version.json';

Enjoy :)