gulp-rev-hash

Appends a file's hash to a file URL to cache assets in any file (html, templates)

gulp-rev-hash

Appends a file's hash to a file URL to cache assets

npm install --save-dev gulp-rev-hash

This example will take the example.html file and add rev tags to all files that are found in this file, with default options.

var gulp = require('gulp');
var rev = require('gulp-rev-hash');
 
gulp.task('rev', function () {
    gulp.src('template.html')
        .pipe(rev())
        .pipe(gulp.dest('.'));
});
<!-- rev-hash -->
<link rel="stylesheet" href="main.min.css"/>
<!-- end -->
 
<!-- rev-hash -->
<script src="abc.js"></script>
<script src="def.js"></script>
<!-- end -->
<link rel="stylesheet" href="main.min.css?v=9d58b7441d92130f545778e418d1317d">
 
<script src="abc.js?v=0401f2bda539bac50b0378d799c2b64e"></script><script src="def.js?v=e478ca95198c5a901c52f7a0f91a5d00"></script>
assetsDir: '/public'

Path to assets in your project