Output

@ Chrome Dev-tool console

console.log(__VERSION__);
"da7698330a678f77............." // git commit HEAD's hash

You can use the DefinePlugin that will make your build info available inlined with your code:

webpack.config.js

const childProcess = require('child_process');

plugins = [
  // ...
  new webpack.DefinePlugin({
    __VERSION__: JSON.stringify(childProcess
      .execSync('git rev-list HEAD --max-count=1').toString()),
  })
];

app.js

if (typeof __VERSION__ === 'string') {
  (window as any).__VERSION__ = __VERSION__;
}

If you use typescript, append to types/index.d.ts to omit type error

declare const __VERSION__:string;

Ref