在Webpack构建中包括git commit哈希和日期 [英] Including git commit hash and date in webpack build
本文介绍了在Webpack构建中包括git commit哈希和日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用react/es6/webpack.我想在我的应用程序中的某处显示构建和git哈希的日期.最好的方法是什么?
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?
推荐答案
您可以使用webpack的 DefinePlugin :
You can use webpack's DefinePlugin:
// get git info from command line
let commitHash = require('child_process')
.execSync('git rev-parse --short HEAD')
.toString();
...
plugins: [
new webpack.DefinePlugin({
__COMMIT_HASH__: JSON.stringify(commitHash),
})
]
...
然后您可以通过__COMMIT_HASH__
这篇关于在Webpack构建中包括git commit哈希和日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文