0

我有一个基于此示例的指南针 sinatra 项目。

正如在这个拉取请求中的提交这个拉取请求评论中所指出的,sinatra 能够根据请求自动生成编译后的 css 文件。

但是,这似乎是一种浪费,因为即使 css 文件没有更改,服务器也必须重新编译。如果服务器监视更改,根据文件更改重新编译,但会按需提供相同的静态 css 文件,这不是更好吗?这就像我们运行“指南针手表”并只提供编译文件一样工作。

那么我的问题是:有没有一种好方法可以让 sinatra 在更改时自动将我的 sass 文件编译成静态 CSS,而无需单独运行 watch compass?

注意:我还有一个 express/node/stylus 项目,它的行为是这样的,这让我相信这是可能的并且是合乎逻辑的方式,并且我只是错误地配置了我的 sinatra 应用程序。

4

1 回答 1

0

To change the CSS you have to either:

  • push new files to the application server (with a possible restart)
  • recompile in the background (e.g. compass watch on the server)
  • get the server to compile on changes (using something like the example you gave)

Personally, I favour the first. I'm not sure why I'd want the server to compile static assets? It takes up valuable resources, and the CSS changes on my dev machine, so why not compile them on my dev machine? I've not heard good answers to these questions, so I use a Guardfile (or you could use sass watch or compass watch as a background task e.g. sass --watch app/views/stylesheets:app/public/css &) to compile them, and then I check in the .css files and push them to the server.

YMMV.

于 2013-03-06T03:11:04.047 回答