const gulp = require('gulp');
const htmlmin = require('gulp-htmlmin');
const fileinclude = require('gulp-file-include');
const less = require('gulp-less');
const csso = require('gulp-csso');
const babel = require('gulp-babel');
gulp.task('first', () => {console.log('第一次执行');});gulp.task('htmlmin', () => {gulp.src('./src/*.html')//压缩去其中的代码.pipe(fileinclude()).pipe(htmlmin({ collapseWhitespace: true })).pipe(gulp.dest('dist'));
});
gulp.task('cssmin', () => {gulp.src('./src/*.less').pipe(less()).pipe(gulp.dest('dist/css'))});
gulp.task('jsmin', () => {gulp.src('./src/*.js').pipe(babel({presets: ['@babel/env']})).pipe(gulp.dest('dist'))});
gulp.task('copy', () => {gulp.src('./src/img/*').pipe(gulp.dest('dist'))});
//构建任务
gulp.task('default', ['htmlmin', 'ccsmin', 'jsmin', 'copy'])
运行结果