Reputation: 347
gulp.task('minify-css', function () {
gulp.src(['src/test/test.css])
.pipe(concat('test1.css'))
.pipe(minifyCSS())
.pipe(gulp.dest('src/source/'))
.pipe(filesize())
});
gulp.task('copy-css',['minify-css'], function () {
gulp.src('src/source/*.css')
.pipe(gulp.dest('src/dest/'));
});
It seems that the first time I run 'gulp copy-css'
Starting 'minify-css'...
[18:54:39] Finished 'minify-css' after 61 ms
[18:54:39] Starting 'copy-css'...
[18:54:39] Finished 'copy-css' after 1.86 ms
but the copy operation doesn't execute probably because it executes even before the file to be copied is not generated
Even though I have mentioned minify-css as dependency for copy-css task, it seems it is not following that convention in this case.
When gulp copy-css is run another time, this time the file is copied because the file is already generated from previously executed command. But this would beat the purpose when the code is being used in production.
Upvotes: 4
Views: 1382
Reputation: 18055
change both the tasks as below
gulp.task('minify-css', function () {
return gulp.src(['src/test/test.css])
.pipe(concat('test1.css'))
.pipe(minifyCSS())
.pipe(gulp.dest('src/source/'))
.pipe(filesize())
});
gulp.task('copy-css',['minify-css'], function () {
return gulp.src('src/source/*.css')
.pipe(gulp.dest('src/dest/'));
});
add return so that next task runs after first one runs, else your copy-csss is running even before minify-css is finished.. hence the error...
Upvotes: 3
Reputation: 5981
Try with a callback in the on('finish')
event:
gulp.task('minify-css', function (cb) {
gulp.src(['src/test/test.css'])
.pipe(concat('test1.css'))
.pipe(minifyCSS())
.pipe(gulp.dest('src/source/'))
.pipe(filesize())
.on('finish', function() {
// All tasks should now be done
return cb();
})
});
gulp.task('copy-css',['minify-css'], function () {
gulp.src('src/source/*.css')
.pipe(gulp.dest('src/dest/'));
});
PS:
You also go an syntax error in your gulp.src array at the very top, just a missing quote '
here gulp.src(['src/test/test.css])
Upvotes: 1
Reputation: 7739
I would check out this question, as it seems you might have to add return
keyword before gulp.src(['src/test/test.css])
...
Upvotes: 1