[GULP] Gulp - Developing An Application (ok)

https://www.tutorialspoint.com/gulp/gulp_developing_application.htm

Chú ý: Để kết hợp được các task với nhau từ phiên bản 4.x trở đi chúng ta phải

gulp.task('default', gulp.series('css','js'));

Chú ý: Nếu thì sử dụng

gulp.task('default', gulp.series('a', 'b', 'c'));

Thì sử dụng

gulp.task('default', gulp.parallel('a', 'b', 'c'));

Dependencies Declaration

npm install gulp-imagemin --save-dev

You can add dependencies to your configuration file as shown in the following code.

var imagemin = require('gulp-imagemin');

Creating Task for Dependencies

gulp.task('task-name', function() {
   //do stuff here
});

Example

gulp.task('imagemin', function() {
   var img_src = 'src/images/**/*', img_dest = 'build/images';

   gulp.src(img_src)
   .pipe(changed(img_dest))
   .pipe(imagemin())
   .pipe(gulp.dest(img_dest));
});

Running the Task

gulp imagemin

Last updated