[英]Why do I have to use vinyl-source-stream with gulp?
I am trying to use gulp and browserify to transform my .jsx
files into .js
files.我正在尝试使用
.jsx
和.jsx
将我的.jsx
文件转换为.js
文件。
var gulp = require('gulp');
var browserify = require('browserify');
var reactify = require('reactify');
gulp.task('js', function () {
browserify('public/javascripts/src/app.jsx')
.transform(reactify)
.bundle()
.pipe(gulp.dest('public/javascripts/dist'))
});
``` ``
The above threw Arguments to path.resolve must be strings
.上面抛出的
Arguments to path.resolve must be strings
。 I managed to get around it by using vinyl-source-stream
我设法通过使用
vinyl-source-stream
来解决它
var source = require('vinyl-source-stream');
...
.bundle()
.source('app.js')
...
Why does this work?为什么这样做? I am fairly new to nodejs and gulp.
我对 nodejs 和 gulp 相当陌生。 After reading the README of the project and the source code, I am still confused.
看了项目的README和源码,还是一头雾水。 Any help?
有什么帮助吗?
I think that reading this article gulp The vision, history, and future of the project can help you to clarify a few concepts.我认为阅读这篇文章gulp 项目的愿景、历史和未来可以帮助你理清几个概念。
Basically you can say that vinyl-source-stream convert the readable stream you get from browserify into a vinyl stream that is what gulp is expecting to get.基本上,您可以说vinyl-source-stream将从browserify 获得的可读流转换为gulp 期望获得的vinyl 流。
A vinyl stream is a Virtual file format , and it is fundamental for Gulp .乙烯基流是一种虚拟文件格式,它是Gulp 的基础。 Thanks to this vinyl streams Gulp doesn't need to write a temporal file between different transformations.
由于这种乙烯基流, Gulp 不需要在不同的转换之间编写临时文件。 And this is one of the main advantages it has over Grunt .
这是它相对于Grunt的主要优势之一。
这个模块只是一个桥梁,它可以简单地将传统的文本流与 gulp 结合使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.