我有一个Grunt文件,它没有使用gulpif和lazypipes,但是我想要做的是创建一个任务,它将在我的index.html页面中使用useref
来获取脚本文件。然后gulpif
JS lint
,uglify
/concatenate,和notify
。我得到一个“错误:无效的调用lazypipe()..”和我在看这篇文章https://github.com/OverZealous/lazypipe/issues/19,但我有点绿色,不明白错误/如何解决它“pipe(foo)vs.管(FOO())”。 如果有人能告诉我我如何使用lazypipe错误=我应该很好。如何与gulp-if和lazypipe一起使用多个管道?
grunt文件比较大,我使用的是gulpif bc css,一旦这个工作就会使用。如果有更好的方式让我知道,谢谢。
插件使用:
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
notify = require('gulp-notify'),
gulpif = require('gulp-if'),
lazypipe = require('lazypipe'),
useref = require('gulp-useref');
uglify = require('gulp-uglify');
var anyJS = '/**/*.js',
distFolder = 'dist';
//Lazy Tasks
var jsTask = lazypipe()
.pipe(jshint)
.pipe(jshint.reporter('jshint-stylish'))
.pipe(notify('JS Linting finished'))
.pipe(uglify())
.pipe(notify('JS Compressing finished'));
//Tasks
gulp.task('mini', function() {
return gulp.src('./index.html')
.pipe(useref())
.pipe(gulpif(anyJS, jsTask()))
.pipe(gulp.dest(distFolder));
});