Created
February 24, 2015 20:35
-
-
Save sptz45/d7fb9bee926c5c225524 to your computer and use it in GitHub Desktop.
Minimal Gulp setup with ReactJs, Browserify, LESS and BrowserSync for Play Framework
This file contains hidden or 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'), | |
browserify = require('gulp-browserify'), | |
browserSync = require('browser-sync'), | |
less = require('gulp-less'); | |
var path = { | |
js: { | |
src: 'assets/javascripts/', | |
dest: 'target/web/public/main/javascripts/' | |
}, | |
css: { | |
src: 'assets/stylesheets/', | |
dest: 'target/web/public/main/stylesheets/' | |
}, | |
html: { | |
src: 'app/views/' | |
} | |
}; | |
gulp.task('browserify', function() { | |
gulp.src(path.js.src + 'main.js') | |
.pipe(browserify({ transform: 'reactify' })) | |
.pipe(gulp.dest(path.js.dest)); | |
}); | |
gulp.task('less', function () { | |
return gulp.src(path.css.src + '**/*.less') | |
.pipe(less()) | |
.pipe(gulp.dest(path.css.dest)) | |
.pipe(browserSync.reload({stream:true}));; | |
}); | |
gulp.task('watch', function() { | |
gulp.watch(path.js.src + '**/*.js', [ 'browserify', browserSync.reload ]); | |
gulp.watch(path.css.src + '**/*.less', [ 'less' ]); | |
}); | |
gulp.task('serve', function () { | |
browserSync({ | |
proxy: 'localhost:9000', | |
port: 9001, | |
files: [ | |
'app/views/*.html' | |
], | |
open: false, | |
ghostMode: false | |
}); | |
}); | |
gulp.task('default', ['less', 'browserify', 'watch', 'serve']); |
This file contains hidden or 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
{ | |
"dependencies": { | |
"react": "^0.12.2" | |
}, | |
"devDependencies": { | |
"browser-sync": "^2.0.1", | |
"gulp": "^3.8.11", | |
"gulp-browserify": "^0.5.1", | |
"gulp-less": "^3.0.0", | |
"gulp-react": "^2.0.0", | |
"reactify": "^1.0.0" | |
} | |
} |
Reacitfy seems to be deprecated nowadays in favor of babel. Update please?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi I see that you use React, so I am sure that you will find interesting the https://reactjs.co - this is the free online convention and tutorial book for React.JS Developers. React is not only the View (in MVC) anymore. ReactJS For Dummies: Why & How to Learn React Redux, the Right Way.