Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
61
rated 0 times [  63] [ 2]  / answers: 1 / hits: 15467  / 9 Years ago, fri, june 12, 2015, 12:00:00

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'))
});


```



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')
...


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?


More From » node.js

 Answers
6

I think that reading this article gulp
The vision, history, and future of the project
can help you to clarify a few concepts.


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.


A vinyl stream is a Virtual file format, and it is fundamental for Gulp. Thanks to vinyl streams Gulp doesn't need to write temporary files between different transformations. And this is one of the main advantages it has over Grunt.


[#66233] Wednesday, June 10, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
irvingcarloe

Total Points: 677
Total Questions: 109
Total Answers: 96

Location: Svalbard and Jan Mayen
Member since Sun, Sep 25, 2022
2 Years ago
irvingcarloe questions
Wed, Mar 31, 21, 00:00, 3 Years ago
Tue, Aug 4, 20, 00:00, 4 Years ago
Fri, Jul 3, 20, 00:00, 4 Years ago
;