I have gulpfile.js
var gulp = require('gulp'),
browserSync = require('browser-sync');
var clean = require('gulp-clean');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var less = require('gulp-less');
var livereload = require('gulp-livereload');
var watch = require('gulp-watch');
var minifycss = require('gulp-minify-css');
gulp.task('browserSync', function () {
var files = ['app/**'];
browserSync.init(files, {
server: {
baseDir: 'app/',
index: 'index.html'
},
logPrefix: 'Ex02xAth',
browser: ['chrome', 'opera', 'firefox']
});
});
gulp.task('clean', function(){
return gulp.src('app/tmp/*', {read: false})
.pipe(clean());
});
gulp.task('slucovac', function(){
return gulp.src('app/lib/*.js')
.pipe(concat('all.js'))
.pipe(gulp.dest('app/built/'));
});
gulp.task('komprese', function(){
return gulp.src('app/lib/*.js')
.pipe(uglify())
.pipe(gulp.dest('app/minjs/'));
});
gulp.task('watch', function () {
var watcher = gulp.watch('app/html/*.tmpl.html', ['build']);
watcher.on('change', function (event) {
console.log('Event type: ' + event.type); // added, changed, or deleted
console.log('Event path: ' + event.path); // The path of the modified file
});
});
gulp.task('less', function(){
gulp.src('app/less/*.less')
.pipe(watch())
.pipe(less())
.pipe(gulp.dest('app/css/'))
.pipe(livereload());
});
gulp.task('minifycss', function() {
gulp.src('app/css/*.css')
.pipe(minifycss())
.pipe(gulp.dest('app/cssmin/'));
});
gulp.task('default', ['slucovac', 'komprese', 'minifycss', 'browserSync']);
当我运行gulp less
命令行时写道: "插件'吞咽手表'中的错误。消息:需要 glob 参数。
我按照这篇文章进行:http://www.smashingmagazine.com/2014/06/11/building-with-gulp/
我可以寻求帮助吗?谢谢
您需要指定要监视的文件。始终检查文档
gulp.task('less', function(){
gulp.src('app/less/*.less')
.pipe(watch('app/less/*.less'))
.pipe(less())
.pipe(gulp.dest('app/css/'))
.pipe(livereload());
});