A
Search/replacement can be used for simple cases, with assistance https://github.com/lazd/gulp-replace ♪To that end, you'll need to know the new name of the renamed gulp-hash file. This can be done by keeping the list of renamed files with help. hash.manifest('assets.json')and then read it in the task of 'html' to be used to search/replace.Also draw attention to the use of return (in your example, they are not available), otherwise dependent tasks will be launched without waiting for the completion of the tasks on which they depend.In this case, it is important that the task of "js " will first be worked out in order to obtain a new name for the file and then the task of "html " to make a replacement in the text.Example gulpfile.jsvar gulp = require('gulp'),
replace = require('gulp-replace'),
hash = require('gulp-hash');
gulp.task('js', function() {
return gulp.src('src/js/*')
.pipe(hash())
.pipe(gulp.dest('dist'))
.pipe(hash.manifest('assets.json'))
.pipe(gulp.dest('tmp'));
});
gulp.task('html', ['js'], function() {
var assets = require('./tmp/assets.json');
return gulp.src('src/index.html')
.pipe(replace('main.js', assets['main.js']))
.pipe(gulp.dest('dist'));
});
gulp.task('default', ['html'], function() {
});