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?
I couldn't comment to the top post, so here goes:
Webpack.dev.js
import gitprocess from "child_process"
let LoadCommitDate = gitprocess
.execSync('git log -1 --date=format:"%Y/%m/%d %T" --format="%ad"')
.toString()
...
plugins: [
new webpack.DefinePlugin({
COMMITDATE: JSON.stringify(LoadCommitDate),
})
]
Additionally in .eslintrc
"globals": {
"COMMITDATE": "readonly",
},
Result - latest commit date you can reference in your code!
console.log(COMMITDATE)
2020/05/04 21:02:03