Wednesday, 15 May 2019

Add git information to create-react-app

In development, I want to be able to see the build information (git commit hash, author, last commit message, etc) from the web. I have tried:

  • use child_process to execute a git command line, and read the result (Does not work because browser environment)
  • generate a buildInfo.txt file during npm build and read from the file (Does not work because fs is also unavailable in browser environment)
  • use external libraries such as "git-rev"

The only thing left to do seems to be doing npm run eject and applying https://www.npmjs.com/package/git-revision-webpack-plugin , but I really don't want to eject out of create-react-app. Anyone got any ideas?



from Add git information to create-react-app

No comments:

Post a Comment