hakanersu
9/15/2014 - 3:59 PM

My Latest Gulp File

My Latest Gulp File

var gulp            = require("gulp"),
    sass            = require("gulp-ruby-sass"),
    autoprefixer    = require("gulp-autoprefixer"),
    rename          = require('gulp-rename'),
    minifycss       = require('gulp-minify-css'),
    concat          = require('gulp-concat'),
    uglify          = require('gulp-uglify'),
    coffee          = require('gulp-coffee'),
    notify          = require('gulp-notify'),
    plumber         = require('gulp-plumber'); 

// Gulp sass task
gulp.task('css',function(){
    gulp.src("sass/**/*.sass")
        .pipe(plumber())
        .pipe(sass({ style: 'expanded', }))
        .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
        .pipe(gulp.dest('../../public/css'))
        .pipe(rename({ suffix: '.min' }))
        .pipe(minifycss())
        .pipe(gulp.dest('../../public/css'))
        .pipe(notify('All CSS Works Done!'));
});

// Gulp coffee task
gulp.task('js',function(){
     gulp.src("coffee/**/*.coffee")
         .pipe(plumber())
         .pipe(coffee())
         .pipe(concat('main.js'))
         .pipe(gulp.dest('../../public/js'))
         .pipe(rename({ suffix: '.min' }))  
         .pipe(uglify())
         .pipe(gulp.dest('../../public/js'))
         .pipe(notify('All JS Works Done!'));
});

// Gulp watch task
gulp.task('watch',function(){
    gulp.watch('sass/**/*.sass',['css']);
    gulp.watch('coffee/**/*.coffee',['js']);
});

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