Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gulp Browserify + Reactify (JSX) #1

Open
rapind opened this issue Oct 5, 2014 · 2 comments
Open

Gulp Browserify + Reactify (JSX) #1

rapind opened this issue Oct 5, 2014 · 2 comments

Comments

@rapind
Copy link

rapind commented Oct 5, 2014

Would be incredibly useful to see an extension of your browserify vanilla example that included a JSX transform (reactify).

Something along the lines of this gulp-browserify based sample:

gulp.task('javascripts', function() {
  gulp.src('src/javascripts/app.jsx')
    .pipe(browserify({
      insertGlobals: true,
      transform: ['reactify'],
      extensions: ['.jsx']
    }))
    .pipe(gulp.dest('build/javascripts'));
});
@sogko
Copy link
Owner

sogko commented Nov 12, 2014

Hi @rapind, thanks for the suggestion.

I was trying to put forth a generic example with the hopes that it would be easy to translate existing gulp-browserify recipes to a vanilla recipe.

I had previously touched briefly on using reactify transform in the README.md here.
But I guess that gets buried in all of that words.

I guess I could write a separate browserify recipe for reactify.
I would like to gather more use-cases for a typical browserify + reactify builds before that.
Could you share your typical build?

In the mean time, here's a quick one thats equivalent to the one you posted:

var gulp = require('gulp');
var browserify = require('browserify');
var reactify = require('reactify');
var rename = require('gulp-rename');

gulp.task('browserify', function () {

  var browserified = transform(function(filename) {
    var b = browserify(filename, {
      insertGlobals: true,
      extensions: ['.jsx']
    });
    b.transform(reactify);
    return b.bundle();
  });

  return gulp.src('./src/javascripts/app.jsx')
    .pipe(browserified)
    .pipe(rename('app.js') // rename it or else the result file would be `app.jsx`
    .pipe(gulp.dest('./build/javascripts'));
});

@SiZapPaaiGwat
Copy link

you may find solution in this repo https://github.com/Granze/react-starterify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants