Skip to content

Instantly share code, notes, and snippets.

@ro31337
Created March 6, 2016 01:14
Show Gist options
  • Select an option

  • Save ro31337/89429b7cc8f9033a3e24 to your computer and use it in GitHub Desktop.

Select an option

Save ro31337/89429b7cc8f9033a3e24 to your computer and use it in GitHub Desktop.
// convert React components to be used in the browser
gulp.task('browserify', function() {
var babelifyConfig = babelify.configure({presets: ['es2015', 'react'], extensions: ['.jsx']});
return browserify({
entries: 'src/app.jsx', // the same as "--extension=.jsx src/**/*.jsx"
extensions: ['.jsx']
})
.transform(babelifyConfig) // the same as -t command line parameter
.bundle() // "readable stream with the javascript file contents"
.pipe(source('bundle.js')) // "conventional text stream at the start of our gulp pipeline", wrapped with "pipe" method
.pipe(gulp.dest('dist/bundle.js')); // standard gulp way to redirect gulp pipe to directory
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment