加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gulpfile.js 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
chancy 提交于 2018-10-22 10:33 . 新增HTML格式化gulp任务。
const gulp = require('gulp');
const merge = require('merge-stream');
const imagemin = require('gulp-imagemin');
const minifyCSS = require('gulp-minify-css');
const uglify = require('gulp-uglify');
const htmlbeautify = require('gulp-html-beautify');
gulp.task('build', function () {
var imageminHandler = function(){
return imagemin([
imagemin.gifsicle({interlaced: true}),
imagemin.jpegtran({progressive: true}),
imagemin.optipng({optimizationLevel: 5})
],{verbose: true});
}
var s1 = gulp.src('./*.php')
.pipe(gulp.dest('dist/'));
var s2 = gulp.src(['./static/**/*.{png,jpg,jpeg,gif}'])
.pipe(imageminHandler())
.pipe(gulp.dest('dist/static'));
var s3 = gulp.src('helps/*.css')
.pipe(minifyCSS())
.pipe(gulp.dest('./dist/helps'));
var s4 = gulp.src('helps/*.js')
.pipe(uglify())
.pipe(gulp.dest('./dist/helps'));
var s5 = gulp.src('./pxpay/*.php')
.pipe(gulp.dest('dist/pxpay'));
return merge( s1, s2, s3, s4, s5);
});
gulp.task('html-beautify', function(){
var options = {
indentSize: 2
};
var s6 = gulp.src('./dist/helps/*.html')
.pipe(htmlbeautify(options))
.pipe(gulp.dest('dist/helps/'));
var s7 = gulp.src('./dist/*.html')
.pipe(htmlbeautify(options))
.pipe(gulp.dest('dist/'));
return merge( s6, s7 );
});
gulp.task('default', ['build', 'html-beautify']);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化