Skip to content

Instantly share code, notes, and snippets.

@relaxedtomato
Created May 26, 2015 13:46
Show Gist options
  • Save relaxedtomato/b2cfc3d1ed12969d1a77 to your computer and use it in GitHub Desktop.
Save relaxedtomato/b2cfc3d1ed12969d1a77 to your computer and use it in GitHub Desktop.
React + Browserify Gulp Task
/**
* Created by ram on 15-05-03.
*/
var gulp = require('gulp');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var reactify = require('reactify');
var browserify = require('browserify')();
var gutil = require('gulp-util');
var filter = require('gulp-filter');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var sass = require('gulp-sass');
var less = require('gulp-less');
var rename = require('gulp-rename');
//TODO: Figure out cacheing in GULP
gulp.task('compileJS',function(){
console.log('testing');
browserify
.add('./js-src/app.js');
browserify
.transform(babelify);
browserify
.transform(reactify);
//TODO: placing in main for now
browserify
.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest('./public'))
});
//var handleErrors = require('../utils/handleErrors');
//var config = require('../config').sass;
gulp.task('buildCSS', function () {
return gulp.src('./public/main.less')
.pipe(less())
.pipe(rename('style.css'))
.pipe(autoprefixer({ cascade: false, browsers: ['last 2 versions']}))
.pipe(gulp.dest('./public'));
});
gulp.task('default', function(){
gulp.watch('js-src/**/*.js',['compileJS']);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment