Gulp dest method cannot write content

  node.js, question

When performing css compression using gulp-minify-css, gulp.dest cannot directly replace the original file with a compressed file?

The following code cannot get a compressed version of css file

gulp.task('rev', function(){
 var cssPath = '/home/me/project/resource/**/*.css',
 jsPath = '/home/me/project/resource/**/*.js',
 imgPath = '/home/me/project/resource/**/*.png',
 htmlPath = '/home/me/project/templates/**/*.html',
 resourceDir = '/home/me/release/project/resource',
 templateDir = '/home/me/release/project/resource';
 
 gulp.src([cssPath, jsPath, imgPath])
 .pipe(rev())
 .pipe(gulp.dest(resourceDir));
 
 gulp.src(originalHtml)
 .pipe(rev())
 .pipe(gulp.dest(templateDir))
 });
 
 gulp.task('cssmin', ['rev'], function(){
 var cssPath = '/home/me/release/project/resource/**/*.css',
 cssDir = '/home/me/release/project/resource';
 gulp.src(cssPath)
 .pipe(minifyCss())
 .pipe(gulp.dest(cssDir));
 });

After changing the file path of dest, a compressed version of css file can be obtained

gulp.task('cssmin', ['rev'], function(){
 var cssPath = '/home/me/release/project/resource/**/*.css',
 otherDir = '/home/me/release/project/static/temp';  //Other Strengths
 gulp.src(cssPath)
 .pipe(minifyCss())
 .pipe(gulp.dest(otherDir));
 });

Remove the rev task dependency and execute it directly. You can also obtain compressed files under cssDir.

I am a beginner of gulp. I hope the great god can give me some advice.

Just change the code to read as follows:

var cssPath = '/home/me/project/resource/**/*.css',
 jsPath = '/home/me/project/resource/**/*.js',
 imgPath = '/home/me/project/resource/**/*.png',
 htmlPath = '/home/me/project/templates/**/*.html',
 resourceDir = '/home/me/release/project/resource',
 templateDir = '/home/me/release/project/resource';
 
 gulp.task('rev:static', function(){
 return gulp.src([cssPath, jsPath, imgPath])
 .pipe(rev())
 .pipe(gulp.dest(resourceDir));
 });
 
 gulp.task('rev:html', function(){
 return gulp.src(originalHtml)
 .pipe(rev())
 .pipe(gulp.dest(templateDir))
 });
 
 gulp.task('cssmin', ['rev:static', 'rev:html'], function(){
 var cssPath = '/home/me/release/project/resource/**/*.css',
 cssDir = '/home/me/release/project/resource';
 gulp.src(cssPath)
 .pipe(minifyCss())
 .pipe(gulp.dest(cssDir));
 });

Reason: To complete the task that is dependent on before it is executed, the task that is dependent on must: accept a callback, return a stream or return a promise. See the official documents:Gulp api