Created
June 8, 2015 17:26
-
-
Save relaxedtomato/56131ec301229eac3b7e to your computer and use it in GitHub Desktop.
Reactlist gulpfile.js
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
/** | |
* 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'); | |
var plumber = require('gulp-plumber'); | |
var jshint = require('gulp-jshint'); | |
var stylish = require('jshint-stylish'); | |
var runSequence = require('run-sequence'); | |
var react = require("gulp-react"); | |
var babel = require('gulp-babel'); | |
gulp.task('lintJS', function () { | |
gulp.src(['js-src/**/*.js']) | |
.pipe(plumber()) | |
.pipe(react()) //convert from jsx to js for jshint | |
.pipe(jshint({esnext:true})) | |
.pipe(jshint.reporter(stylish)); | |
}); | |
//TODO: Figure out caching in GULP | |
gulp.task('compileJS',function(){ | |
console.log('testing'); | |
var bundler = browserify(); | |
bundler | |
.add('js-src/app.js'); | |
bundler | |
.transform(babelify); | |
bundler | |
.transform(reactify); | |
//TODO: placing in main for now | |
bundler | |
.bundle() | |
.on('error',handleError) | |
.pipe(plumber()) | |
.pipe(source('app.js')) | |
.pipe(gulp.dest('public')) | |
}); | |
function handleError(error){ | |
console.log('error',error.toString()); | |
} | |
//var handleErrors = require('../utils/handleErrors'); | |
//var config = require('../config').sass; | |
gulp.task('buildCSS', function () { | |
return gulp.src('public/main.less') | |
.pipe(plumber()) | |
.pipe(less()) | |
.pipe(rename('style.css')) | |
.pipe(autoprefixer({ cascade: false, browsers: ['last 2 versions']})) | |
.pipe(gulp.dest('public')); | |
}); | |
gulp.task('default', function(){ | |
gulp | |
.start('compileJS') | |
.watch('js-src/**/*.js',function(){runSequence('lintJS','compileJS')}); | |
}); | |
//TODO: Add something for css watch | |
// | |
//.watch('*.js',function(){ | |
// runSeq('lintJS','testJS'); | |
//}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment