You can use webpack’s DefinePlugin:
// get git info from command line
let commitHash = require('child_process')
.execSync('git rev-parse --short HEAD')
.toString()
.trim();
...
plugins: [
new webpack.DefinePlugin({
__COMMIT_HASH__: JSON.stringify(commitHash)
})
]
...
Then you can use it in your app with __COMMIT_HASH__