Version Stamping your App with the Angular CLI – Austin – Medium

  • Version Stamping your App with the Angular CLIWhen building applications, you typically need some way to show the build version somewhere in your app.
  • Lets write a script that will get the Git hash and the version from the package.json.
  • This looks something like this:Lets hook this script up to run on postinstall of our application.
  • So navigate to your package.json and add this line to the scripts:{ scripts: { “postinstall”: “node version.js” }}Now anytime we run npm i our app version will get updated for us.This script will create a file in our environments folder called version.ts.
  • Now we have our versions showing up in our app.

When building applications, you typically need some way to show the build version somewhere in your app. This can be tricky when using a closed-ecosystem tool like the Angular CLI. So how do we do it…

@amcdnl: [Blog] Version Stamping your App with the Angular CLI – #angular #angular2 #angularcli #javascript

Version Stamping your App with the Angular CLIWhen building applications, you typically need some way to show the build version somewhere in your app. This can be tricky when using a closed-ecosystem tool like the Angular CLI. So how do we do it then??Lets write a script that will get the Git hash and the version from the package.json. This looks something like this:Lets hook this script up to run on postinstall of our application. So navigate to your package.json and add this line to the scripts:{ scripts: { “postinstall”: “node version.js” }}Now anytime we run npm i our app version will get updated for us.This script will create a file in our environments folder called version.ts. It will look something like this:We can now import that file in any component like:Presto! Now we have our versions showing up in our app. That example just shows the semver but with the git script we have we can add the git hash too!I’m #ngPandaI hope you enjoyed the post, if you liked it follow me on Twitter and Github for more JavaScript

Version Stamping your App with the Angular CLI – Austin – Medium

稿源:JSFeeds (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » Version Stamping your App with the Angular CLI – Austin – Medium

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录