var gulp      = require('gulp'),
    gutil     = require('gulp-util'),
    rimraf    = require('gulp-rimraf');
    source    = require('vinyl-source-stream'),
    streamify = require('gulp-streamify');

// cleaning tasks
gulp.task('cleanjs', function () {
    gulp.src('./dist/js')
        .pipe(rimraf());
});

gulp.task('cleancss', function () {
    gulp.src('./dist/css')
        .pipe(rimraf());
});

gulp.task('stylus', ['cleancss'], function () {
    var stylus = require('gulp-stylus'),
        prefix = require('gulp-autoprefixer');

    gulp.src('./styl/main.styl')
        .pipe(stylus({linenos: true}))
        .pipe(prefix())
        .pipe(gulp.dest('./dist/css'));
});

gulp.task('hint', function () {
    var cached  = require('gulp-cached'),
        jshint  = require('gulp-jshint'),
        stylish = require('jshint-stylish');

    return gulp.src('./js/**/*.js')
        .pipe(cached('hinting'))
        .pipe(jshint())
        .pipe(jshint.reporter(stylish));
});

gulp.task('js', ['cleanjs', 'hint'], function () {
    var browserify = require('browserify'),
        uglify     = require('gulp-uglify');

    return browserify('./js/main.js', {
            transform: ['hbsfy'],
            debug: true
        })
        .bundle()
        .pipe(source('main.js'))
        .pipe(streamify(uglify()))
        .pipe(gulp.dest('./dist/js'));
});

// a task responsible for all compilation
gulp.task('build', ['stylus', 'js']);


gulp.task('watch', ['stylus'], function () {
    var watchify   = require('watchify'),
        browserify = require('browserify'),
        bundler    = watchify(browserify('./js/main.js', {
            cache: {},
            packageCache: {},
            fullPaths: true,
            transform: ['hbsfy'],
            debug: true
        }));

    function rebundle() {
        var t = Date.now();
        gutil.log('Starting Watchify rebundle');
        return bundler.bundle()
            .pipe(source('main.js'))
            .pipe(gulp.dest('./dist'))
            .on('end', function () {
                gutil.log('Finished bundling after:', gutil.colors.magenta(Date.now() - t + ' ms'));
            });
    }
    bundler.on('update', rebundle);
    gulp.watch('./js/**/*.js', ['hint']);
    gulp.watch('./styl/**/*.styl', ['stylus']);

    return rebundle();
});

gulp.task('default', ['build']);

@@ -193,16 +193,321 @@
 eamify')
+,%0A    sequence  = require('run-sequence'),%0A    %0A    // check to see if a %60--prod%60 flag was passed to gulp%0A    prod      = gulp.env.prod;%0A%0A// toggle the production flag without passing an argument%0Agulp.task('setProduction', function () %7B%0A    // set the prod variable that we added above%0A    prod = true;%0A%7D)
 ;%0A%0A// cl
@@ -837,16 +837,61 @@
 efixer')
+,%0A        minify = require('gulp-minify-css')
 ;%0A%0A    g
@@ -949,20 +949,21 @@
 inenos: 
-true
+!prod
 %7D))%0A    
@@ -978,24 +978,70 @@
 e(prefix())%0A
+        .pipe(prod ? minify() : gutil.noop())%0A
         .pip
@@ -1600,36 +1600,37 @@
          debug: 
-true
+!prod
 %0A        %7D)%0A    
@@ -1690,16 +1690,23 @@
   .pipe(
+prod ? 
 streamif
@@ -1716,16 +1716,31 @@
 glify())
+ : gutil.noop()
 )%0A      
@@ -1858,16 +1858,256 @@
 js'%5D);%0A%0A
+// add a task that always runs %60build%60 in production mode%0Agulp.task('prod', function () %7B%0A    // use the run-sequence module to make sure%0A    // %60setProduction%60 happens before other tasks%0A    sequence('setProduction', %5B'stylus', 'js'%5D)%0A%7D);%0A
 %0Agulp.ta

Add production flag and task