What exactly does .pipe() mean in gulp?

女生的网名这么多〃 提交于 2019-11-30 05:39:07

From the Node docs:

https://nodejs.org/api/stream.html#stream_readable_pipe_destination_options

The readable.pipe() method attaches a Writable stream to the readable, causing it to switch automatically into flowing mode and push all of its data to the attached Writable. The flow of data will be automatically managed so that the destination Writable stream is not overwhelmed by a faster Readable stream.

So in Gulp you can chain multiple tasks together using the pipe() method. Gulp makes use of streams. There are readable and writeable streams. Take the following snippet for example:

gulp.src(config.jsSrc)
    .pipe(uglify())
    .pipe(gulp.dest(config.dest + '/js'))
    .pipe(size());

gulp.src(...) turns the path at config.jsSrc into a readable stream of data that we are then piping to the gulp-uglify module. The uglify task returns a stream that we then pipe to our destination and so on...

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!