I need to display git revision on my angular2 application\'s about page. The project is based on angular-cli.
How can build be extended so git revision is put for exampl
I've done it by generating prebuild script run on postinstall and run before any angular related script
const fs = require('fs');
const git = require('git-rev-sync');
var mkdirp = require('mkdirp');
const releaseTag = git.tag();
const template = `export const gitTag = '${releaseTag}';\n`;
mkdirp('./generated', function(err) {
fs.writeFileSync('./generated/git-tag.ts', template, { encoding: 'UTF-8' });
});
which generated git-tag.ts file:
export const gitTag = 'xxxxxxx';
and now u just use in component
import { gitTag } from '[pathToRoot]/generated/git-tag';
also add .gitignore
generated