I\'m using react/es6/webpack. I want to show the date of the build and git hash somewhere in my app. What\'s the best approach?
Another way of doing this is ( in ANGULAR + REACT ) :
Just install this package git-revision-webpack-plugin
Simple webpack plugin that generates VERSION and COMMITHASH files during build based on a local git repository.
Sample Code :
Inside your webpack.config.js (or any dev - prod file)
const GitRevisionPlugin = require('git-revision-webpack-plugin');
const gitRevisionPlugin = new GitRevisionPlugin();
plugins: [
new DefinePlugin({
'VERSION': JSON.stringify(gitRevisionPlugin.version()),
'COMMITHASH': JSON.stringify(gitRevisionPlugin.commithash()),
'BRANCH': JSON.stringify(gitRevisionPlugin.branch()),
}),
]
In your Component (React):
export class Home extends Component{
....
render() {
return(
{VERSION}
{COMMITHASH}
{BRANCH}
)
}
}
In your Template (Angular):
{{ VERSION }}
{{ COMMITHASH }}
{{ BRANCH }}