3

I have gulpfile.js

var gulp = require('gulp'),
browserSync = require('browser-sync');
var clean = require('gulp-clean');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var less = require('gulp-less');
var livereload = require('gulp-livereload');
var watch = require('gulp-watch');
var minifycss = require('gulp-minify-css');

gulp.task('browserSync', function () {
  var files = ['app/**'];

 browserSync.init(files, {
    server: {
       baseDir: 'app/',
       index: 'index.html'
    },
   logPrefix: 'Ex02xAth', 
   browser: ['chrome', 'opera', 'firefox']
 });
});

gulp.task('clean', function(){
  return gulp.src('app/tmp/*', {read: false})  
   .pipe(clean());
});

gulp.task('slucovac', function(){
  return gulp.src('app/lib/*.js')
   .pipe(concat('all.js')) 
   .pipe(gulp.dest('app/built/'));
});

gulp.task('komprese', function(){
  return gulp.src('app/lib/*.js')
  .pipe(uglify())
  .pipe(gulp.dest('app/minjs/'));
});

gulp.task('watch', function () {
  var watcher = gulp.watch('app/html/*.tmpl.html', ['build']);
  watcher.on('change', function (event) {
    console.log('Event type: ' + event.type); // added, changed, or deleted
    console.log('Event path: ' + event.path); // The path of the modified file
  });
});

gulp.task('less', function(){
  gulp.src('app/less/*.less')
   .pipe(watch())
   .pipe(less())
   .pipe(gulp.dest('app/css/'))
   .pipe(livereload());
});  

gulp.task('minifycss', function() {
  gulp.src('app/css/*.css')
   .pipe(minifycss())
   .pipe(gulp.dest('app/cssmin/'));
});

gulp.task('default', ['slucovac', 'komprese', 'minifycss', 'browserSync']);

When I run gulp less command line wrote: "Error in plugin 'gulp-watch'. Message: glob argument required."

I proceeded according this article: http://www.smashingmagazine.com/2014/06/11/building-with-gulp/

Can I ask for help? Thanks

ondra15
  • 143
  • 4
  • 16

1 Answers1

7

You need to specify which files to watch. Always check documentation

gulp.task('less', function(){
  gulp.src('app/less/*.less')
   .pipe(watch('app/less/*.less'))
   .pipe(less())
   .pipe(gulp.dest('app/css/'))
   .pipe(livereload());
});
zaynetro
  • 2,298
  • 20
  • 28