javascript-Gulp.js:重新载入更改过的php / html页面
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript-Gulp.js:重新载入更改过的php / html页面,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2114字,纯文字阅读大概需要4分钟。
内容图文
![javascript-Gulp.js:重新载入更改过的php / html页面](/upload/InfoBanner/zyjiaocheng/679/24aba12a72604f45a5b9291e2c466180.jpg)
我在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文件时,它都会自动刷新每个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 ...
有什么方法可以让我只重新保存已保存的页面吗?这似乎是我无法完全按照我的意愿工作的唯一方法.我爱它比奔跑快多少.
编辑:@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));
});
});
解决方法:
请改用gulp-watch plugin.查看单个文件,然后仅将其传递给结果,会更好.另外,如果您使用watch({glob:[‘files’]}).pipe(…)而不是gulp.src([‘files’]).pipe(watch( )).管(…).
另一种选择是使用gulp-newer或gulp-changed,它们都使用时间戳来确定文件是否已更改.我也没有个人使用过,但是gulp-newer似乎有更多的功能.但是,两者都将无法检测到新文件.
内容总结
以上是互联网集市为您收集整理的javascript-Gulp.js:重新载入更改过的php / html页面全部内容,希望文章能够帮你解决javascript-Gulp.js:重新载入更改过的php / html页面所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。