简体   繁体   English

水管工,通知和自定义错误功能使我在插件“水管工”中出现错误:消息:无法通过管道传递给未定义

[英]Plumber, notify and a custom error fucntion give me an Error in plugin 'plumber': Message: Can't pipe to undefined

I'm building a Wordpress theme starter app in node, gulp and also handlebars to create templates. 我正在节点,gulp和车把中构建Wordpress主题入门应用程序以创建模板。

I'm having an issue with plumber, notify and gulp-sass plugins working together. 我在管道工,通知和gulp-sass插件一起工作时遇到问题。

Here is a link to my repo: https://github.com/elassol/wp-theme 这是我的仓库的链接: https : //github.com/elassol/wp-theme

every time I try to compile sass with my gulp task I get an error: 每次我尝试用gulp任务编译sass时,都会出现错误:

Error in plugin 'plumber' Message: Can't pipe to undefined 插件“管道工”错误消息:无法通过管道传递给未定义

I have a Pumbler error function, a SASS TASK to preprocess sass and a gulp watch task to fire the sass taks when a file change. 我有一个Pumbler错误功能,一个SASS任务以预处理Sass和一个gulp watch任务在文件更改时触发sass taks。

 var gulp = require('gulp'); var gutil = require('gulp-util'); var autoprefixer = require('gulp-autoprefixer'); var sass = require ('gulp-sass'); var plumber = require('gulp-plumber'); var notify = require('gulp-notify'); var browserSync = require('browser-sync'); var cache = require('gulp-cache'); var imageOpt = require('gulp-image-optimization'); var jshint = require('gulp-jshint'); var useref = require('gulp-useref'); var uglify = require('gulp-uglify'); var gulpIf = require('gulp-if'); var clean = require('gulp-clean'); var cssnano = require('gulp-cssnano'); var concat = require('gulp-concat'); var del = require('del'); var runSequence = require('run-sequence'); var sourcemaps = require('gulp-sourcemaps'); var fs = require('fs'); // ========================================================== // Pumbler error function // ========================================================== function customPlumber(errTitle) { return plumber({ errorHandler: notify.onError({ // Customizing error title title: errTitle || "Error running Gulp", message: "Error: <%= error.message %>", sound: "Glass" }) }); } // ========================================================== // STYLES TASK // ========================================================== gulp.task('sass', function(){ return gulp.src(paths.styles.src + '**/*.scss') .pipe(customPlumber('Error Running Sass')) // inititalizr sourcemap before anyother pluging that alter files .pipe(sourcemaps.init()) .pipe(sass({ includePaths: ['theme/bower_components'], precision: 2 })) .pipe(autoprefixer({ browsers: ['ie 8-9', 'last 2 versions'] })) .pipe(sourcemaps.write('./')) .pipe(gulp.dest(paths.styles.build)) .pipe(browserSync.reload()) }) // ========================================================== // WATCH TASK // ========================================================== gulp.task('watch', ['browserSync'], function(){ gulp.watch(basePaths.src + 'sass/**/*.scss', ['sass']); gulp.watch(paths.scripts.src + '**/*.js', browserSync.reload); gulp.watch('theme/*.html', browserSync.reload); gulp.watch('theme/js/**/*.js', ['jshint']); }) 

Any ideas what I'm doing wrong or at least point me to the right direction? 有什么想法我做错了,或者至少指出了正确的方向吗?

Thanks in advance people! 在此先感谢大家!

custom error function doesn't throw the error. 自定义错误功能不会引发错误。 there is some undefined pipe at pipeline. 管道中有一些未定义的管道。 it seems undefined pipe at sourcemaps lines. 在sourcemaps行上似乎未定义管道。 u should require gulp-sourcemaps. 您应该需要gulp-sourcemaps。


after edit: in this case u should change 编辑后:在这种情况下,您应该更改

  .pipe(sync.reload());

line like this 像这样的线

  .pipe(sync.reload({stream:true}));

additional explanion 附加说明

in gulp task there should be a stream throught the pipeline. 在gulp任务中,应该有一条流经管道的流。 every pipe should return the stream object for pass the stream to next pipe. 每个管道都应返回流对象,以将流传递到下一个管道。

at first version of your code; 您的代码的第一个版本; sync, broking the stream cycle because of reload method returns nothing. 同步,由于重载方法中断了流周期,因此不会返回任何内容。 and gulp throwing an error for this reason. 并且由于这个原因,gulp抛出错误。 stream:true property try to inject the streams and returning the incoming stream back. stream:true属性尝试注入流并将返回的流返回。 this is it. 就是这个。

actually u can use sync.stream() instead of sync.reload(). 实际上,您可以使用sync.stream()而不是sync.reload()。 or if u dont want to inject your styles u can apply like this example 或者,如果您不想注入您的样式,则可以像以下示例一样应用

https://www.browsersync.io/docs/gulp/#gulp-reload https://www.browsersync.io/docs/gulp/#gulp-reload

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM