Last active
January 25, 2016 12:57
-
-
Save sibinx7/8268679cb1923ca527b5 to your computer and use it in GitHub Desktop.
React babelify with gulp, gulp task to compile React in ES2015/ES6 mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp') | |
var browserify = require("browserify") | |
var babelify = require("babelify") | |
var source = require('vinyl-source-stream'); | |
var livereload = require('gulp-livereload'); | |
gulp.task("react",function(){ | |
return browserify({ | |
entries:'./app/assets/javascripts/react/main.js', | |
debug: true | |
}) | |
.transform("babelify",{presets:["react","es2015","stage-0"],plugins:["transform-es2015-arrow-functions"]}) | |
.bundle() | |
.pipe(source("bundle.js")) | |
.pipe(gulp.dest("./app/assets/javascripts")) | |
.pipe(livereload()) | |
}) | |
gulp.task("watch",["react"],function(){ | |
livereload.listen({basePath:'public'}) | |
gulp.watch("./app/assets/javascripts/react/*/*.js",["react"]) | |
}) | |
gulp.task("default",["watch"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "react-app", | |
"version": "1.0.0", | |
"description": "Sample Application using React and Rails to learn react ", | |
"main": "index.js", | |
"directories": { | |
"test": "test" | |
}, | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [ | |
"react", | |
"js", | |
"rails", | |
"flux", | |
"react", | |
"router" | |
], | |
"author": "Sibin Xavier", | |
"license": "ISC", | |
"devDependencies": { | |
"babel": "^6.3.26", | |
"babel-core": "^6.4.5", | |
"babel-preset-es2015": "^6.3.13", | |
"babel-preset-react": "^6.3.13", | |
"babel-preset-stage-0": "^6.3.13", | |
"babel-register": "^6.4.3", | |
"babelify": "^7.2.0", | |
"browserify": "^13.0.0", | |
"gulp": "^3.9.0", | |
"gulp-livereload": "^3.8.1", | |
"gulp-util": "^3.0.7", | |
"gulp-watchify": "^0.5.0", | |
"vinyl-source-stream": "^1.1.0" | |
}, | |
"dependencies": { | |
"flux": "^2.1.1", | |
"jquery": "^2.2.0", | |
"react": "^0.14.6", | |
"react-dom": "^0.14.6" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment