2016-03-15 77 views
0
gulp.task('live', function() { 
    // listen for changes 
    livereload.listen(); 

    // watch less files in src (to start just type gulp in the src directory) 
    gulp.watch('public/css/**/*.less', ['src-less-to-css', 'src-less-to-css-ie8', 'src-less-to-css-ie9']); 
    gulp.watch('public/**/*', livereload()); // <--- this ain't working 

    // configure nodemon 
    nodemon({ 
     // the script to run the app 
     script: 'app.js', 
     ext: 'js', 
     ignore: ['public/**/*'] 
    }).on('restart', function(){ 
     // when the app has restarted, run livereload. 
     gulp.src('app.js') 
      .pipe(livereload()) 
      .pipe(notify('Reloading page, please wait...')); 
    }) 
}); 

所以我想調用livereload()方法,只要公共directoy中的文件發生更改,不管哪個文件,任何內容和所有內容。使用livereload()直接與手錶?

我希望像上面的一個簡單的解決方案。

回答

1

確定找到了一個廉價的解決方案,不知道這是否是雖然是最好的。

gulp.watch('public/**/*', ['reload']); 

此功能:

// used by the public watch 
gulp.task('reload', function() { 
    return gulp.src('app.js') 
     .pipe(livereload()); 
});