gulp 监控打包
onst gulp = require('gulp');
const less = require('gulp-less');
const plumber = require('gulp-plumber');
const minify = require('gulp-minify-css');
const connect = require('gulp-connect');
const concat = require('gulp-concat');
gulp.task('less', function () {
gulp.src('./src/less/*.less')
.pipe(plumber())
.pipe(less())
.pipe(concat('index.css'))
.pipe(minify())
.pipe(gulp.dest('./src/css'))
.pipe(connect.reload());
});
gulp.task('html', function () {
gulp.src('index.html')
.pipe(connect.reload());
});
gulp.task('connect', function () {
connect.server({
livereload: true
});
});
//定义看守任务
gulp.task('watchHTML', function () {
gulp.watch('index.html', ['html']);
});
gulp.task('watchLESS', function () {
gulp.watch(['./src/less/*.less'], ['less']);
});
gulp.task('default', ['watchHTML', 'watchLESS', 'connect']);