2017-02-25 8 views
0

しばらくwatchifyを使用しようとしていて、保存に問題があります。gulp watchifyに変更を含めるには2回の保存が必要

すべての変更のようですが、出力に変更を適用するために2回保存する必要があります。

jsファイルにコードを追加すると、新しく追加されたコードは、タスクが2回実行された場合にのみ表示されます。

"観る" のための私のコードmainScrpitsタスク

var customOpts = { 
     entries: ['./app/app.js'], 
     debug: true 
    }; 
    var opts = assign({}, watchify.args, customOpts); 
    var b = watchify(browserify(opts)); 


    gulp.task('mainScripts', bundle); 
    b.on('update', bundle); 
    b.on('log', gutil.log); 

    function bundle() { 
     console.log('bundle'); 
     return b.bundle() 
     .on('error', gutil.log.bind(gutil, 'Browserify Error')) 
     .pipe(source('main.js')) 
     .pipe(buffer()) 
     .pipe(gulpif(!condition, sourcemaps.init({ 
      loadMaps: true 
     }))) 
     .pipe(gulpif(!condition, sourcemaps.write('./'))) 
     .pipe(gulp.dest('./dist/js/')) 
     .pipe(gulpif(isLocal(), connect.reload())); 
    } 

はどちらもwatchifyとgulp.watchがあなたのファイルにその変更を探している

gulp.task('watch', function() { 
    gulp.watch('app/**/*.js', ['mainScripts']); 
}); 

答えて

1

を-taskバンドルの作成時に競合条件が発生します。魅力のように働いた

gulp.task('watch', function() { 
    gulp.start('mainScripts'); 
}); 
+0

あなたの時計の仕事は自​​分のmainScriptsタスクを開始する必要があります! – Joel

関連する問題