我有一个基本的gulp.js设置在我的wordpress环境中运行。除了我重新加载更改后的.php文件的方式外,一切都可以运行。我有它设置如下:Gulp.js:刷新改变的php/html页面
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 ...
有没有一种方法,我可以只有livereload保存的页面?这似乎是我无法工作的唯一方式,我想要如何喝一口水;不过,我喜欢它跑得比咕噜快多少。
编辑:@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));
});
});
我希望看到你的完整配置,一饮而尽,因为我试图用一口运行PHP的服务器和livereload当我改变PHP/PHTML,CSS和js文件。 – SirTophamHatt
我上面发布了我的观看任务,因为整个文件看起来好像很多帖子,但是如果您愿意,我可以找到一种发布更多的方法! – thesublimeobject
你可以把它张贴在jsfiddle或plunkr上吗?这对我得到livereload使用PHP来说是一个巨大的帮助。 – SirTophamHatt