'use strict';

var gulp = require('gulp');
var less = require('gulp-less');
var LessAutoprefix = require('less-plugin-autoprefix');
var jsmin = require('gulp-jsmin');
var rename = require('gulp-rename');
var watch = require('gulp-watch');

var autoprefix = new LessAutoprefix({ browsers: ['last 2 versions'] });

function handleError(err) {
  console.log(err.toString());
  // this.emit('end');
}

gulp.task('scripts', function () {
    gulp.src('./js/guibik.js')
        .pipe(jsmin())
        .pipe(rename({suffix: '.min'}))
        .pipe(gulp.dest('./js/'));
});

gulp.task('styles', function () {
  gulp.src('./less/guibik.less')
    .pipe(less({
      plugins: [autoprefix]
    }))
    .pipe(gulp.dest('./css/'));
});

gulp.task('default', function () {
});

// default gulp task
gulp.task('default', ['scripts', 'styles'], function() {
  gulp.watch('./less/*.less', ['styles']);
  gulp.watch('./js/*.js', ['scripts']);
});
