【问题标题】:How to write JavasScript project using guard-livereload?如何使用 guard-livereload 编写 JavaScript 项目?
【发布时间】:2012-08-11 10:40:18
【问题描述】:

我想开始学习 JS。 我找到了 gem guard-livereload。

在我的 Rails 应用程序中,它运行良好。但我想用它为简单的 JS 脚本重新加载本地文件。

所以我将guard-livereload 安装到 rvm gemset global。创建新目录javascript 添加到Guardfile

# https://github.com/guard/guard-livereload
guard :livereload do
  watch(%r{.+\.(html|css|js)$})
end

使用 Livereload 扩展 (1.6) 打开 Chrome

这是来自我的控制台:

> guard                                                                                                                                                                    /Users/rege/Code/javascript 1.9.3p194 @
Guard could not detect any of the supported notification libraries.
Guard is now watching at '/Users/rege/Code/javascript'
LiveReload 1.6 is waiting for a browser to connect.
Browser connected.
Browser URL: file://localhost/Users/rege/Code/javascript/examples/example_1_2.html
Reloading browser: examples/example_1_2.html
Reloading browser: examples/example_1_2.html
Reloading browser: examples/example_1_2.html

我的卫士版本:

> gem list guard                                                                                                                                                           /Users/rege/Code/javascript 1.9.3p194 @

*** LOCAL GEMS ***

guard (1.3.0)
guard-livereload (1.0.0)

似乎一切正常,但 Chrome 不刷新页面。

【问题讨论】:

  • 它也对我不起作用。我发现这个适用于 Firefox 的插件也适用于 JavaScript:stackoverflow.com/questions/8710613/…
  • 您的问题帮助我使用了livereload,谢谢! (我不知道我必须运行guard 命令)

标签: javascript ruby google-chrome google-chrome-extension guard


【解决方案1】:

在 Chrome 中,您必须明确授予文件 url 的扩展权限。右键单击 LiveReload 图标,转到管理扩展,并授予 LiveReload 文件 url 权限。

【讨论】:

    猜你喜欢
    • 2014-03-07
    • 1970-01-01
    • 2014-12-24
    • 2012-02-01
    • 2013-04-03
    • 2013-12-02
    • 2015-01-15
    • 2016-05-07
    • 2013-04-21
    相关资源
    最近更新 更多