Answer the question
In order to leave comments, you need to log in
gulp-rev not working correctly, what is wrong with my gulp file?
Good afternoon!
Here is part of my gulpfile.js
gulp.task('clean', function(){
del(['static/build/*.min.*'])
});
gulp.task('build-less', function(){
gulp.src(['static/legacy/**/*.+(css|less)', 'static/less/**/*.+(css|less)'])
.pipe(postcss([ nested, short, autoprefixer(), cssnano(), cssnext, cssvariables() ]))
.pipe(concatCSS('main.css'))
.pipe(rename('styles.min.css'))
.pipe(rev())
.pipe(gulp.dest('static/build'))
.pipe(rev.manifest({
base: './',
merge: true // merge with the existing manifest (if one exists)
}))
.pipe(gulp.dest('./'));
});
gulp.task('build-legacy-js', function(){
gulp.src(['static/legacy/**/*.js'])
.pipe(concat('all.js'))
.pipe(rename('bundle.min.js'))
.pipe(rev())
.pipe(gulp.dest('static/build'))
.pipe(rev.manifest({
base: './',
merge: true // merge with the existing manifest (if one exists)
}))
.pipe(gulp.dest('./'));
});
gulp.task('build-scripts-js', function(){
gulp.src(['static/js/**/*.js'])
.pipe(concat('all.js'))
.pipe(rename('scripts.min.js'))
.pipe(rev())
.pipe(gulp.dest('static/build'))
.pipe(rev.manifest({
base: './',
merge: true // merge with the existing manifest (if one exists)
}))
.pipe(gulp.dest('./'));
});
gulp.task('default', ['clean', 'build-less', 'build-legacy-js', 'build-scripts-js']);
gulp.task('watch', function(){
gulp.watch('static/less/*.+(css|less)', ['build-less']);
gulp.watch('static/js/**/*.js', ['build-scripts-js']);
gulp.watch('static/legacy/**/*.js', ['build-legacy-js']);
});
{
"bundle.min.js": "bundle-af26fd17a0.min.js",
"scripts.min.js": "scripts-87dd6e8894.min.js"
}
Answer the question
In order to leave comments, you need to log in
The problem is most likely that gulp runs its tasks asynchronously, i.e. it does not run one after the other, but all at once, and therefore merge sometimes does not work correctly. I had such that the rev manifest file was generally written in parts. And accordingly it was not valid. Something like that:
{
"bundle.min.js": "bundle-af26fd17a0.min.js"
}4hg28f1v.min.js
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question