gulp.watch错误地处理文件

时间:2014-02-15 15:08:06

标签: gulp gulp-less

我正在运行一个简单的脚本,将HAML和LESS转换为PHP和CSS。我也在使用gulp.watch检查我所做的所有更改。

问题:gulp-less和gulp-haml正确处理文件。但是当gulp.watch看到文件中的更改时,文件最终为空。 gulp.watch正在使用完全相同的任务,成功创建了php文件。

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']);

0 个答案:

没有答案