我安装了必要的宝石,如下所示:
~/Desktop/html5$ gem list
bundle (0.0.1)
bundler (1.3.5)
coderay (1.0.9)
em-websocket (0.5.0)
eventmachine (1.0.3)
ffi (1.8.1)
formatador (0.2.4)
guard (1.8.0)
guard-livereload (1.4.0)
guard-sass (1.2.0)
这就是我的Guardfile的样子:
~/Desktop/html5$ more Guardfile
A sample Guardfile
More info at https://github.com/guard/guard#readme
guard 'livereload' do
watch(%r{.+\.(css|js|html)$})
end
这是我跑步时得到的:捆绑执行警卫
~/Desktop/html5$ bundle exec guard
12:05:56 - INFO - Guard uses NotifySend to send notifications.
12:05:56 - INFO - Guard uses TerminalTitle to send notifications.
12:05:56 - INFO - LiveReload is waiting for a browser to connect.
12:05:56 - INFO - Guard is now watching at '/home/praveen/Desktop/html5'
[1] guard(main)>
为了确保Guard服务器正在运行,这是我在telneting
时得到的 :~/Desktop/html5$ telnet 127.0.0.1 35729
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
当我对受监控目录中的index.html进行更改时,这就是我在警卫提示中获得的内容
13:36:20 - INFO - Browser connected.
13:36:25 - INFO - Reloading browser: index.html
13:36:34 - INFO - Reloading browser: index.html
[1]后卫(主要)>
我已经安装了chrome live reload插件并给它文件读取权限,但是当我点击它时,它不会改变,因此不会将代码更改重新加载到/ home / praveen / Desktop /中的任何html或css html5,请告诉我可以做些什么。
普利文
答案 0 :(得分:4)
经过2天的努力,这是我想在Ubuntu 13.04上毫不费力地工作的方法,因此它使我的工作流程无缝:
将LiveReload从Python和CD安装到需要监视更改的目录
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
pip install livereload
sudo apt-get install python-pip
pip install livereload
cd FolderToBeMonitored/
创建一个名为Guardfile的文件,其中包含以下内容,以监控对html和css文件的所有更改
Desktop/html5$ more Guardfile
#!/usr/bin/env python
from livereload.task import Task
Task.add('*.css')
Task.add('*.html')
Task.add('css/*.css')
praveen@praveen-XPS-L412Z:~/Desktop/html5$
完成上述操作后,使用以下命令启动LiveReload:
livereload -b
请注意,liveReload使用35729作为默认端口,但如果需要更改为TO 1717,请使用
livereload -p 1717 -b
默认的html文件将在默认浏览器中自动启动,无需安装任何错误的Chrome扩展程序。要启动特定文件,请使用以下格式的相应网址
http://127.0.0.1:35729/test.html
我更喜欢这种Ruby gem安装,然后是需要连接到端口方法的chrome扩展,我在这个问题上花了2天时间,直到找出上面没有任何chrome插件的方法时它才能工作。< / p>
答案 1 :(得分:1)
我设法使用它作为保护文件 我有Ubuntu 13.04 raringtail
# This will concatenate the javascript files specified in :files to public/js/all.js
guard :concat, type: "js", files: %w(), input_dir: "public/js", output: "public/js/all"
guard :concat, type: "css", files: %w(), input_dir: "public/css", output: "public/css/all"
guard 'livereload' do
watch(%r{/.+\.(css|html|js)$})
end
guard 'sass', :input => 'sass', :output => 'css'
输出是终端中的输出:
* dany @ dany:/ var / www / tucan $ guard 21:07:04 - INFO - Guard正在使用NotifySend发送通知。 21:07:04 - INFO - Guard正在使用TerminalTitle发送通知。 21:07:04 - INFO - LiveReload正在等待浏览器连接。 21:07:04 - 信息 - 警卫正在观看'/ var / www / tucan' [1]后卫(主要)&gt; 21:07:23 - 信息 - 浏览器已连接。 21:07:23 - 信息 - 浏览器已连接。 *
希望这有助于某人