SORU
13 Mart 2014, PERŞEMBE


Yudum yudum.yeni ve silinmiş dosyaları için değil tetikledi izle?

Aşağıdaki şu maçta dosyaları düzenlerken görev çalışıyor Gulpjs:

// watch task.
gulp.task('watch', ['build'], function () {
    gulp.watch(src   '/js/**/*.js', ['scripts']);
    gulp.watch(src   '/img//**/*.{jpg,jpeg,png,gif}', ['copy:images']);
    gulp.watch(src   '/less/*.less', ['styles']);
    gulp.watch(src   '/templates/**/*.{swig,json}', ['html']);
});

// build task.
gulp.task('build', ['clean'], function() {
    return gulp.start('copy', 'scripts', 'less', 'htmlmin');
});

Ancak (yumurtlama) yeni veya silinmiş dosyalar için çalışmıyor. Kaçırdığım bir şey mi var?

EDİT: kullanarak çalışıyor gibi görünüyor değil eklenti grunt-izlemek bile:

gulp.task('scripts', function() {
    return streamqueue(
        { objectMode: true },
        gulp.src([
            vendor   '/jquery/dist/jquery.min.js',
            vendor   '/bootstrap/dist/js/bootstrap.min.js'
        ]),
        gulp.src([
            src   '/js/**/*.js'
        ]).pipe(plugins.uglify())
    )
    .pipe(plugins.concat(pkg.name   '.min.js'))
    .pipe(gulp.dest(dest   '/js/'));
});

gulp.task('watch', ['build'], function () {
    plugins.watch({glob: src   '/js/**/*.js'}, function () {
        gulp.start('scripts');
    });
});

EDİT: Çözüldü, this issue. Renk teorisi ./ ile başlayan (src değeri) ATM çalışıyor gibi görünüyor.

CEVAP
13 Mart 2014, PERŞEMBE


Bir şey eksik değil mi. gulp.watch yeni veya silinmiş dosyaları ile çalışmaz. Basit bir çözüm basit projeler için tasarlanmıştır.

Yeni dosyalar için bakabilirsiniz dosya izlemek için kullanmak çok daha güçlü olan the gulp-watch plugin,. Kullanımı bu gibi görünüyor:

var watch = require('gulp-watch');

// in a task
watch({glob: <<glob or array of globs>> })
        .pipe( << add per-file tasks here>> );

// if you'd rather rerun the whole task, you can do this:
watch({glob: <<glob or array of globs>>}, function() {
    gulp.start( <<task name>> );
});

Şahsen ben ilk seçeneği öneririm. Bu çok daha hızlı, her dosya işlemleri için izin verir. Gelişimi sırasında herhangi bir dosya bitiştirmek değil mi sürece livereload ile harika çalışıyor.

my lazypipe library, ya da sadece böyle bir fonksiyonu ve stream-combiner kullanma ya da akarsu sarın

var combine = require('stream-combiner');

function scriptsPipeline() {
    return combine(coffeeescript(), uglify(), gulp.dest('/path/to/dest'));
}

watch({glob: 'src/scripts/**/*.js' })
        .pipe(scriptsPipeline());

GÜNCELLEMEEkim 15, 2014

@Aşağıda pkyeck tarafından belirttiği gibi, görünüşte gulp-watch 1.0 sürümü biraz biçim değiştirdi, yukarıdaki örnekler Evet:

var watch = require('gulp-watch');

// in a task
watch(<<glob or array of globs>>)
        .pipe( << add per-file tasks here>> );

// if you'd rather rerun the whole task, you can do this:
watch(<<glob or array of globs>>, function() {
    gulp.start( <<task name>> );
});

ve

var combine = require('stream-combiner');

function scriptsPipeline() {
    return combine(coffeeescript(), uglify(), gulp.dest('/path/to/dest'));
}

watch('src/scripts/**/*.js')
        .pipe(scriptsPipeline());

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Jucyber Tutoriais

    Jucyber Tuto

    8 EYLÜL 2009
  • MysteryGuitarMan

    MysteryGuita

    16 HAZİRAN 2006
  • The Fashion Sight

    The Fashion

    22 AĞUSTOS 2011