var gulp        = require('gulp'),
    less        = require('gulp-less'),
    cssmin      = require('gulp-cssmin'),
    browserSync = require('browser-sync'),
    reload      = browserSync.reload,
    uglify      = require('gulp-uglify'),
    concat      = require('gulp-concat'),
    changed     = require('gulp-changed'),
    runSequence = require('run-sequence'),
    plumber     = require('gulp-plumber'),
    spritesmith = require('gulp.spritesmith');

var path = {
  js: ['dev/assets/js/**/*.js', '!dev/assets/js/**/*.min.js'],
  less: ['dev/assets/less/**/*.less'],
  css: ['dev/assets/css/**/*.css', '!dev/assets/css/**/*.min.css'],
  img: ['dev/assets/img/**/*'],
  html: ['dev/**/*.html']
};

gulp.task('sprite', function () {
  var spriteData = gulp.src('assets/img/partials/*.png')
  .pipe(spritesmith({
    imgName: 'sprite.png',
    cssName: 'sprite.css'
  }));
  return spriteData.pipe(gulp.dest('assets/img/'));
});

gulp.task('less', function () {
  return gulp.src(path.less)
    .pipe(changed('dev/assets/css/'))
    .pipe(plumber({
      errorHandler: function (err) {
        console.log([
          'Errrroou!',
          'Mensagem: ' + err.message + '',
          ' Arquivo: ' + err.fileName + '',
          '   Linha: ' + err.lineNumber + '',
        ].join('\n'));
        this.emit('end');
      }
    }))
    .pipe(less())
    .pipe(cssmin())
    .pipe(gulp.dest('dev/assets/css/'))
    .pipe(reload({stream:true}));
});

gulp.task('sync', function() {
  browserSync({
    server: {
      baseDir: "./dev"
    }
  });
});

gulp.task('html', function () {
  return gulp.src(path.html)
    .pipe(reload({stream:true}));
});

gulp.task('watch', function () {
  gulp.watch(path.less, ['less']);
  gulp.watch(path.html, ['html']);
});

gulp.task('js:build', function () {
  return gulp.src(path.js)
    .pipe(uglify({outSourceMap: true}))
    .pipe(plumber({
      errorHandler: function (err) {
        console.log([
          'Errrroou!',
          'Mensagem: ' + err.message + '',
          ' Arquivo: ' + err.fileName + '',
          '   Linha: ' + err.lineNumber + '',
        ].join('\n'));
        this.emit('end');
      }
    }))
    .pipe(gulp.dest('build/assets/js/'));
});

gulp.task('move:build', function () {
  return gulp.src([
    'dev/**',
    '!dev/assets/less',
    '!dev/assets/less/**/*.less',
    '!dev/assets/js',
    '!dev/assets/js/**/*.js'
  ])
  .pipe(gulp.dest('build/'));
});

gulp.task('default', ['less', 'watch', 'sync']);
gulp.task('build', function () {
  runSequence('less', 'js:build', 'move:build');
});

@@ -1135,32 +1135,32 @@
 %0A          '
-Mensagem
+    Erro
 : ' + err.me
@@ -1149,38 +1149,35 @@
   Erro: ' + err.
-messag
+nam
 e + '',%0A        
@@ -1172,39 +1172,39 @@
 '',%0A          ' 
-Arquivo
+ plugin
 : ' + err.fileNa
@@ -1193,32 +1193,30 @@
 in: ' + err.
-fileName
+plugin
  + '',%0A     
@@ -1217,32 +1217,32 @@
 %0A          '
-   Linha
+Mensagem
 : ' + err.li
@@ -1235,34 +1235,31 @@
 em: ' + err.
-lineNumber
+message
  + '',%0A     
@@ -1956,32 +1956,32 @@
 %0A          '
-Mensagem
+    Erro
 : ' + err.me
@@ -1970,38 +1970,35 @@
   Erro: ' + err.
-messag
+nam
 e + '',%0A        
@@ -2005,15 +2005,15 @@
   ' 
-Arquivo
+ plugin
 : ' 
@@ -2022,16 +2022,14 @@
 err.
-fileName
+plugin
  + '
@@ -2046,16 +2046,16 @@
    '
-   Linha
+Mensagem
 : ' 
@@ -2064,18 +2064,15 @@
 err.
-lineNumber
+message
  + '

Ajuste template less