gulpgulp-rev

How to use gulp-rev with file.revHash?


from gulp-rev @ link : https://github.com/sindresorhus/gulp-rev I have wrote a task to simple

gulp.task('build-app', function () {
   return gulp
        .src([gulpConfig.clientApp + '*.js'])
        .pipe($.rev())
// i want to get the updated hash, which I will use to replace the string in some place

}

Any idea how to acheive it ?


Solution

  • You can use gulp-filenames to store the new/hashed filename. I haven't done this with gulp-rev but I have with gulp-freeze

    gulp.task('css', function () {
        return gulp.src('./js/**/*.js')
            .pipe(freeze())
            .pipe(filenames('some-string'))
            .pipe(gulp.dest('./dist'));
    });
    

    Then in another task you can get that hashed filename with:

    filenames.get('some-string');