代码拉取完成,页面将自动刷新
let gulp = require('gulp');
let cssmin = require('gulp-cssmin');
let autoprefixer = require('gulp-autoprefixer');
let uglify = require('gulp-uglify');
let babel = require('gulp-babel');
let htmlmin = require('gulp-htmlmin');
// let fileInclude = require('gulp-file-include');
let imagemin = require('gulp-imagemin');
function cssHandler() {
return gulp
.src('./src/css/*.css')
.pipe(autoprefixer())
.pipe(cssmin())
.pipe(gulp.dest('./dist/css/'))
}
function jsHandler() {
return gulp
.src('./src/js/*.js')
.pipe(babel({
presets: ['@babel/preset-env']
}))
.pipe(uglify())
.pipe(gulp.dest('./dist/js/'))
}
function htmlHandler() {
return gulp
.src('./src/views/*.html')
.pipe(htmlmin({
removeComments: true,
removeEmptyAttributes: true,
removeAttributeQuotes: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
minifyCSS: true,
minifyJS: true,
}))
.pipe(gulp.dest('./dist/views/'))
}
function imageHandler() {
return gulp
.src('./src/images/**.*')
.pipe(imagemin())
.pipe(gulp.dest('./dist/images/'))
}
let _default = gulp.parallel(cssHandler,jsHandler,htmlHandler,)
module.exports = {
cssHandler,
jsHandler,
htmlHandler,
// imageHandler,
_default:_default
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。