Why do I have to use vinyl-source-stream with gulp?(为什么我必须在 gulp 中使用vinyl-source-stream?)
问题描述
我正在尝试使用 gulp 和 browserify 将我的 .jsx 文件转换为 .js 文件.
I am trying to use gulp and browserify to transform my .jsx files into .js files.
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'))
});
```
上面抛出的path.resolve 的参数必须是字符串.我设法通过使用 vinyl-source-stream
The above threw Arguments to path.resolve must be strings. I managed to get around it by using vinyl-source-stream
var source = require('vinyl-source-stream');
...
.bundle()
.source('app.js')
...
为什么会这样?我对 nodejs 和 gulp 还很陌生.看了项目的README和源码,还是一头雾水.有什么帮助吗?
Why does this work? I am fairly new to nodejs and gulp. After reading the README of the project and the source code, I am still confused. 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.
基本上你可以说 vinyl-source-stream 转换 可读流你从 browserify 得到的 vinyl 流 这就是 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.
乙烯基流是一种虚拟文件格式,它是Gulp的基础.多亏了这个乙烯基流,Gulp 不需要在不同的转换之间编写临时文件.这是它优于 Grunt 的主要优势之一.
A vinyl stream is a Virtual file format, and it is fundamental for Gulp. Thanks to this vinyl streams Gulp doesn't need to write a temporal file between different transformations. And this is one of the main advantages it has over Grunt.
这篇关于为什么我必须在 gulp 中使用vinyl-source-stream?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么我必须在 gulp 中使用vinyl-source-stream?
基础教程推荐
- 每次设置弹出窗口的焦点 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
