1

I'm running a simple script that turns HAML and LESS into PHP and CSS. I'm also using gulp.watch to check up on all the changes I make.

Problem: gulp-less and gulp-haml process the files correctly. But when gulp.watch sees a change in the file the file ends up empty. gulp.watch is using the exact same task that succesfully created the php file.

var gulp = require('gulp');
var gutil= require('gulp-util');
var path = require('path');
var haml = require('gulp-haml');
var less = require('gulp-less');

// Images
gulp.task('less', function() {
    return gulp.src('wp-content/themes/luento/assets/less/*.less')
        .pipe(less({paths: [ path.join(__dirname, 'less', 'includes') ]}))
        .pipe(gulp.dest('wp-content/themes/luento/assets/css/'));
});

gulp.task('haml-def', function () {
    return gulp.src('wp-content/themes/luento/*.haml')
        .pipe(haml({ext: '.php'}))
        .pipe(gulp.dest('wp-content/themes/luento/'));
});

gulp.task('haml-templates', function () {
    return gulp.src('wp-content/themes/luento/templates/*.haml')
        .pipe(haml({ext: '.php'}))
        .pipe(gulp.dest('wp-content/themes/luento/templates/'));
});

gulp.task('haml-partials', function () {
    return gulp.src('wp-content/themes/luento/partials/*.haml')
        .pipe(haml({ext: '.php'}))
        .pipe(gulp.dest('wp-content/themes/luento/partials/'));
});

// Watch
gulp.task('watch', function() {
    // Watch .scss files
    gulp.watch('wp-content/themes/luento/templates/*.haml', ['haml-templates']);
    gulp.watch('wp-content/themes/luento/partials/*.haml', ['haml-partials']);
    gulp.watch('wp-content/themes/luento/*.haml', ['haml-def']);
    gulp.watch('wp-content/themes/luento/assets/less/*.less', ['less'])

});

gulp.task('default', ['less', 'haml-def', 'haml-templates','haml-partials','watch']);
  • Just to make sure - you run `gulp` everything compiles. You make edit to `*.haml` or `*.less` and the build files are empty? – Kelly J Andrews Feb 17 '14 at 13:40
  • See http://stackoverflow.com/questions/22582329/gulp-watch-node-js-usage-messing-up-file-permissions-on-apache-server for an equally strange (and still unsolved) issue with gulp.watch. – dgo Mar 25 '14 at 19:43

0 Answers0