我正在使用 gulp 构建我的 angularjs 应用程序,并想以某种方式将最新的 git commit 哈希注入(inject)到我的 angular 应用程序中,以便我可以在调试生产问题时使用它。
即使只是将它作为一个全局变量注入(inject)到我的 index.html 模板中也很好。
谁能推荐一个好的技术和插件来实现这个?
最佳答案
我最终使用了 git-rev-sync和 gulp-replace并将 {{git}} 放入我的 index.html 源文件中。
var git = require('git-rev-sync');
return gulp.src(pathConfig.src + 'index.html')
.pipe($.replace('{{git}}', git.long()))
.pipe(gulp.dest(pathConfig.dest + 'index.html'));
关于angularjs - 在 gulp 构建期间将 git commit hash 添加到 javascript 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34653198/