自动刷新浏览器以响应文件系统更改? [英] Automatically refresh browser in response to file system changes?

查看:22
本文介绍了自动刷新浏览器以响应文件系统更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在进行 Web 开发时,您经常进行更改,然后刷新浏览器.有没有一种简单的方法可以让守护进程监听文件系统中的变化,当有变化时,向 Firefox 或 Safari 发送刷新消息?

When doing web development, you frequently make changes and then refresh the browser. Is there an easy way to have a daemon listening for changes in the filesystem, and when there is one, to send a refresh message to Firefox or Safari?

这将真正改善您的工作流程和专注度.您可以让浏览器在单独的屏幕上运行,当您处理 UI 相关更改时,它会在您工作时自动刷新.

This would really improve your workflow and focus. You could keep your browser running in a separate screen, and when you're working on UI related changes, it would automatically refresh as you're working.

这就像在进行 TDD 时使用自动测试.(参见 http://github.com/svoop/autotest-fsevent)

It would be like using autotest when doing TDD. (See http://github.com/svoop/autotest-fsevent)

有人做过吗?

推荐答案

我可以想出一种方法来为 Firefox 执行此操作.您安装 MozRepl 插件.然后,您可以启动它并 telnet 到端口 4242(默认情况下)并通过它控制浏览器.Javascript 命令.发出 BrowserReload() 将重新加载当前选项卡.

I can think of a way to do this for Firefox. You install the MozRepl plugin. You can then have it start up and telnet to port 4242 (by default) and control the browser via. Javascript commands. Issuing a BrowserReload() will reload the current tab.

现在,当保存当前项目中的任何文件时,添加一个编辑器挂钩来执行此操作,并且会得到处理.我相信有一些片段已经做到了这一点.

Now, add an editor hook to do that when any files in the current project are saved and it'll be taken care of. I believe there are some snippets around that already do this.

我不太使用 Safari 或 Chrome,所以我不知道那里的选项.

I don't use Safari or Chrome too much so I don't know about options there.

另外,我不确定这真的是个好主意.我不希望我的浏览器在 每个 文件保存时刷新.我通常会对后端、css 甚至图像进行大量更改,然后当我准备好时,重新加载浏览器选项卡.这不是每次保存.无论如何,这会做你想做的.

Also, I'm not sure this is a good idea really. I don't want my browser to refresh on every file save. I usually make a bunch of changes to the backend, css and maybe even images and then when I'm ready, reload the browser tab. It's not per save. Anyway, this will do what you want.

这篇关于自动刷新浏览器以响应文件系统更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆