5

私は gulp を使用して特定のファイルを監視し、特定のタスクを実行していますが、最初の数回の実行後に監視を停止しているようです。ページ ディレクトリに html ファイルを保存すると、最初の 2 ~ 5 回の更新後に、テンプレート タスクの実行が停止したように見えます。以下にgulpfileを含めました。

// Include gulp
var gulp = require('gulp');

// Include plugins
var jshint  = require('gulp-jshint');
var sass    = require('gulp-sass');
var notify  = require('gulp-notify')
var htmlv   = require('gulp-html-validator')
var swig    = require('gulp-swig');
var plumber = require('gulp-plumber');

// Linting
gulp.task('lint', function() {
    return gulp.src('js/*.js')
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

gulp.task('sass', function() {
    return gulp.src('./resources/scss/*.scss')
        .pipe(sass()
            .on('error', notify.onError(function(error) {
                return 'Error: ' + error.message;
            }))
         )
        .pipe(gulp.dest('./css'));
});

gulp.task('validate', function() {
    return gulp.src('./**.html')
        .pipe(htmlv({format: 'xhtml'}))
        .pipe(gulp.dest('./validation_out'));
});

gulp.task('watch', function() {
    gulp.watch('js/*.js', ['lint']);
    gulp.watch('./resources/scss/*.scss', ['sass']);
    gulp.watch('./pages/*.html', ['templates']);
});

gulp.task('templates', function() {
    return gulp.src('./pages/*.html')
        .pipe(swig({
            load_json: true,
            defaults: {
                cache: false
                }
            }
        ))
        .pipe(gulp.dest('.'));
});

gulp.task('default', ['lint', 'sass', 'templates', 'watch']);
4

0 に答える 0