Design.io无法热推代码 [英] Design.io can't hot-push code

查看:103
本文介绍了Design.io无法热推代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试将design.io与node.js Express结合使用,以将CSS/javascript热推到浏览器中, 我克隆了示例 https://github.com/viatropos/design.io-example 并且无法在之后进行热部署

Trying to use design.io with node.js Express to get css/javascript hot-push into browsers, I cloned the example https://github.com/viatropos/design.io-example and couldn't get it to hot deploy after

  1. 遵循 https://github.com/viatropos/中的说明design.io-example/README.md

shell-1-project-dir> design.io --watch ./src

shell-1-project-dir> design.io --watch ./src

错误:未知选项'--watch'

error: unknown option `--watch'

按照 https://github.com/viatropos/design上的说明进行操作.io/README.md

shell-1-project-dir> design.io开始

shell-1-project-dir> design.io start

shell-2-project-dir> design.io手表

shell-2-project-dir> design.io watch

[2012年5月6日,星期日,格林尼治标准时间] INFO更新了views/.index.jade.swp

[Sun, 06 May 2012 03:52:04 GMT] INFO updated views/.index.jade.swp

[2012年5月6日,星期日,格林尼治标准时间(GMT)]信息更新了views/index.jade

[Sun, 06 May 2012 03:52:04 GMT] INFO updated views/index.jade

[2012年5月6日,星期日,格林尼治标准时间(GMT)]信息更新了views/.index.jade.swp

[Sun, 06 May 2012 04:03:11 GMT] INFO updated views/.index.jade.swp

[2012年5月6日,星期日,格林尼治标准时间] INFO更新了views/index.jade

[Sun, 06 May 2012 04:03:11 GMT] INFO updated views/index.jade

这样做,由于node.js不是,我无法访问 http://localhost:4181/开始.我必须先启动node.js.

Doing this, I can't access the http://localhost:4181/ because node.js isn't started. I have to start node.js instead.

shell-1-project-dir>节点server.js

shell-1-project-dir> node server.js

但是,这不会热推更改的index.jade文件.

However this doesn't hot-push the changed index.jade file.

好像这个例子已经过时了吗?

Seems like the example is outdated?

如何热部署?

Env:

 OSX-LION
 node 0.6.15

推荐答案

首先,您可以在其他终端窗口中运行节点服务器(无需运行design.io服务器或节点服务器,只要它们在不同的端口上,您就可以同时运行两者.

First, you can have your node server running in a different terminal window (you don't need to run either the design.io server or the node server, you can run both at the same time as long as they are on different ports).

第二,我不认为这可以满足您的要求. Design.io似乎是用于注入对样式表和javascript文件之类的静态客户端文件所做的更改.更改.css文件后,design.io看到更改并将其广播到浏览器,浏览器中的design.io会强制重新加载样式表,从而完成更改的热推.

Second, I don't think this does what you want it to. Design.io seems to be for injecting changes made to static client files like stylesheets and javascript files. You change a .css file, design.io sees the change and broadcasts it to the browser, design.io in the browser forces a stylesheet reload, completing the hot push of the change.

玉文件是另一回事,它们需要由解释器处理后才能发送到浏览器(浏览器不理解玉文件). Design.io将看到更改,但对此无能为力,因为Node.js需要处理新文件并将更新后的响应发送到浏览器.这样做的唯一方法是刷新浏览器页面(从而发送新请求),而这并不是真正的热交换.

Jade files are a different story, they need to be processed by an interpreter before being sent to the browser (browsers don't understand jade files). Design.io will see the change but can't do anything about it since Node.js needs to process the new file and send an updated response to the browser. The only way it does this is if you refresh the browser page (thereby sending a new request) which is not really a hot swap.

这篇关于Design.io无法热推代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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