var gulp = require('gulp');


var autoprefixer = require('gulp-autoprefixer');
var gutil = require('gulp-util');
var minifyCSS = require('gulp-minify-css');
var rename = require('gulp-rename');
var sass = require('gulp-ruby-sass');


gulp.task('sass', function() {
  return sass('public/stylesheets/style.scss', {
      style: 'expanded',
      noCache: true
    })
    .on('error', function(err) {
      gutil.beep();
      console.error(err);
      this.emit('end');
    })
    .pipe(autoprefixer())
    .pipe(gulp.dest('public/css/'))
    .pipe(minifyCSS())
    .pipe(rename({
      suffix: '.min'
    }))
    .pipe(gulp.dest('public/css/'));
});

gulp.task('watch', function() {
    gulp.watch('public/stylesheets/*.scss', ['sass']);

});

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