Welcome to Shaun Luttin's public notebook. It contains rough, practical notes. The guiding idea is that, despite what marketing tells us, there are no experts at anything. Sharing our half-baked ideas helps everyone. We're all just muddling thru. Find out more about our work at bigfont.ca.

Use Gulp to Watch {LESS} Files and Build on Change

Tags: less, gulp, web-development, client-side, node, npm

var gulp = require('gulp');
var less = require('gulp-less');
var path = require('path');
var watch = require('gulp-watch');
var rename = require('gulp-rename');

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

    console.log('Default task');

});

gulp.task('less', function() {

  return gulp.src('./Content/bigfont/less/bigfont.less')
    .pipe(less())
    .pipe(rename({suffix: '.min'}))
    .pipe(gulp.dest('./Content/bigfont/css/'));

});

gulp.task('watch', function() {

  watch('**/*.less', function () {
    gulp.start('less');
  });

});

References