// Dependencies
var $			= require('gulp-load-plugins')();
var gulp		= require('gulp');
var jeet		= require('jeet');


// Paths
var paths = {
	src: {
		css: 'src/css/**/*.styl',
		js: 'src/js/**/*.js'
	},
	
	build: {
		css: 'assets/css',
		js: 'assets/js'
	}
};


// Default Task
gulp.task('default', ['css', 'js']);


// Watch 
gulp.task('watch', function() {
	gulp.watch(paths.src.css, ['css']);
	gulp.watch(paths.src.js, ['js']);
});


// Process all stylus files
gulp.task('css', function() {
	return gulp.src(paths.src.css)
		.pipe($.stylus({
			use: [jeet]
		}))
		.pipe($.minifyCss())
		.pipe($.autoprefixer())
		.pipe(gulp.dest(paths.build.css));
});


// Process all javascript files
gulp.task('js', function() {
	return gulp.src(paths.src.js)
		.pipe($.uglify())
		.pipe(gulp.dest(paths.build.js));
});
// Dependencies
var $			= require('gulp-load-plugins')();
var Gulp		= require('gulp');
var Jeet		= require('Jeet');


// Paths
var paths = {
	src: {
		css: 'src/css/**/*.styl',
		js: [
			'src/bower/react/react.min.js',
			'src/bower/reqwest/reqwest.min.js',
			'src/react/**/*.jsx',
			'src/js/main.jsx'
		]
	},
	
	build: {
		css: 'assets/css',
		js: 'assets/js',
	}
};


/**
 * Check if is jsx file
 * @param {object} Vinyl file object
 * @return {boolean}
 */
function isJSX(file) {
	var ext = '.jsx';
	var startIndex = file.path.length - ext.length;
	
	return file.path.indexOf(ext, startIndex) !== -1 ? true : false;
}


// Default Task
Gulp.task('default', ['css', 'js']);


// Watch 
Gulp.task('watch', function() {
	Gulp.watch(paths.src.css, ['css']);
	Gulp.watch(paths.src.js, ['js']);
});


// Process all stylus files
Gulp.task('css', function() {
	return Gulp.src(paths.src.css)
		.pipe($.plumber())
		.pipe($.stylus({
			use: [Jeet]
		}))
		.pipe($.minifyCss())
		.pipe($.autoprefixer())
		.pipe($.rename('main.min.css'))
		.pipe(Gulp.dest(paths.build.css));
});


// Process all javascript files
Gulp.task('js', function() {
	return Gulp.src(paths.src.js)
		.pipe($.plumber())
		.pipe($.if(isJSX, $.react()))
		.pipe($.concat('main.min.js'))
		.pipe(Gulp.dest(paths.build.js));
});

Update gulpfile