collapseBooleanAttributes: true,//省略布尔属性的值 <input checked="true"/> ==> <input />
removeEmptyAttributes: true,//删除所有空格作属性值 <input /> ==> <input />
removeScriptTypeAttributes: true,//删除<script>的type="text/javascript"
removeStyleLinkTypeAttributes: true//删除<style>和<link>的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