var gulp    = require('gulp')
  , gutil   = require('gulp-util')
  , uglify  = require('gulp-uglify')
  , sass    = require('gulp-ruby-sass')
  , connect = require('connect')

gulp.task('uglify', function() {
  gulp.src('js/src/*.js')
      .pipe(uglify())
      .pipe(gulp.dest('js/dest'))
})

gulp.task('sass', function() {
  gulp.src('sass/main.scss')
      .pipe(sass({
          compass: true
        , bundleExec: true
        , style: 'compressed'
      }))
      .pipe(gulp.dest('css'))
})

gulp.task('fonts', function() {
  gulp.src('sass/fonts/**')
      .pipe(gulp.dest('css/fonts'))
})

gulp.task('default', function() {
  gulp.watch('js/src/*.js', function() {
    gulp.run('uglify')
  })
  gulp.watch('sass/*.scss', function() {
    gulp.run('sass')
  })
  gulp.watch('sass/fonts/**', function() {
    gulp.run('fonts')
  })

  connect.createServer(
      connect.static(__dirname)
  ).listen(8080)
  console.log('Listening on http://localhost:8080')
})
