collapsebooleanattributes: true,//省略布尔属性的值 618a513d64dc731524b226851e903854 ==> 73a3ca28445b1c625f2086a50cb8c7df
removeemptyattributes: true,//删除所有空格作属性值 c6f04000d9d1c57edc5e7037b92c9cf1 ==> 73a3ca28445b1c625f2086a50cb8c7df
removescripttypeattributes: true,//删除3f1c4e4b6b16bbbd69b2ee476dc4f83a的type=text/javascript
removestylelinktypeattributes: true//删除c9ccee2e6ea535a969eb3f532ad9fe89和2cdf5bf648cf2f33323966d7f58a7f3f的type=text/css
};
return gulp.src(['bucketsrc/*/*.html','bucketsrc/*.html'])
.pipe(htmlmin(options))
.pipe(gulp.dest('bucketdist'));
});
gulp.task('minifycss', function() {
return gulp.src(['bucketsrc/s/c/*/*.css','bucketsrc/s/c/*.css']) //压缩的文件
.pipe(minify())
.pipe(gulp.dest('bucketdist/s/c')) ; //输出文件夹
});
gulp.task('minifyjs',function(){
return gulp.src('bucketsrc/s/j/*/*.js')
.pipe(uglify())
.pipe(gulp.dest('bucketdist/s/j'))
});
gulp.task('clean', function(cb) {
del(['bucketdist/*/*.html','bucketdist/*.html','bucketdist/s/img/*.*','bucketdist/s/c/*/*.css','bucketdist/s/c/*.css','bucketdist/s/j/*/*.js'], cb)
});
gulp.task('images', function() {
return gulp.src('bucketsrc/s/img/*.*')
.pipe(imagemin({
progressive: false
}))
.pipe(gulp.dest('bucketdist/s/img'));
});
gulp.task('default', ['clean', 'testhtmlmin', 'minifycss','images','minifyjs']);
4,命令行中运行gulp default
以上就是利用gulp实现压缩的实例的详细内容。
