我有一個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));
});