wordpress 環境で基本的な gulp.js セットアップを実行しています。変更した .php ファイルをリロードする方法を除いて、すべてが思いどおりに機能します。私はそれを次のように設定しました:
gulp.task('php', function(){
gulp.src('../*.php').pipe(livereload(server));
});
gulp.task('watch', function() {
server.listen(35729, function (err) {
if (err) {
return console.log(err)
};
gulp.watch('styl/src/*.scss', ['styl']);
gulp.watch('js/src/*.js', ['js']);
gulp.watch('../*.php', ['php']);
});
});
基本的に、phpファイルが保存されるたびにページをリロードするだけですが、ファイルを保存するたびに、開いているかどうか、保存されているかどうか、またはその他のすべてのphpページが自動的に更新されます。
[gulp] footer.php was reloaded.
... Reload /Users/KBD/sites/vi/cnt/themes/vi/footer.php ...
[gulp] front-page.php was reloaded.
... Reload /Users/KBD/sites/vi/cnt/themes/vi/front-page.php ...
[gulp] functions.php was reloaded.
... Reload /Users/KBD/sites/vi/cnt/themes/vi/functions.php ...
[gulp] header.php was reloaded.
... Reload /Users/KBD/sites/vi/cnt/themes/vi/header.php ...
[gulp] index.php was reloaded.
... Reload /Users/KBD/sites/vi/cnt/themes/vi/index.php ...
[gulp] social-media.php was reloaded.
... Reload /Users/KBD/sites/vi/cnt/themes/vi/social-media.php ...
[gulp] template-contact.php was reloaded.
... Reload /Users/KBD/sites/vi/cnt/themes/vi/template-contact.php ...
[gulp] template-interior.php was reloaded.
... Reload /Users/KBD/sites/vi/cnt/themes/vi/template-interior.php ...
保存されたページのみをライブリロードする方法はありますか? これは、gulp で思いどおりに動作しない唯一のことのようです。ただし、うなり声よりもどれだけ速く実行されるかが気に入っています。
編集:@SirTophamHatt
gulp.task('watch', function() {
server.listen(35729, function (err) {
if (err) {
return console.log(err)
};
gulp.watch('styl/src/*.scss', ['styl']);
gulp.watch('js/src/*.js', ['js']);
gulp.watch('js/src/*.coffee', ['coffee']);
gulp.src('../*.php').pipe(watch()).pipe(livereload(server));
});
});