rails assets stylesheets config.rb

时间:2013-02-21 13:45:24

标签: ruby-on-rails asset-pipeline

我有这个文件app / assets / stylesheets / config.rb,其中包含以下内容:

http_path = "/"
css_dir = "."
sass_dir = "."
images_dir = "img"
javascripts_dir = "js"
output_style = :compressed
relative_assets=true
line_comments = false

它的用途是什么?

3 个答案:

答案 0 :(得分:5)

要回答您的问题“它是什么”,它是Compass scss编译器的配置。另一个答案中的参考是很方便的,但是对于最新的细节没有推测,请在此处查看Compass配置文件的详细信息:

http://compass-style.org/help/tutorials/configuration-reference/

我最初发布的内容也提供了文件来源的答案(如果你自己没有创建它。我回答这个问题是因为它在我的Rails项目中出现了'魔法',以及谷歌搜索的一代Rails中的config.rb最终在这里。我首先接受了sass-rails,但是该项目的某个人确认他们没有生成该文件。然后我发现该文件的自动生成是由SubLime Text和LiveReload引起的包。请参阅相关的github issue

答案 1 :(得分:0)

我猜它定义了如何从stylesheets文件夹中查找资产,以及一些输出选项,了解资产在发送到客户端浏览器之前会发生什么。

http_path = "/"              <= probably the root path to assets, so if you had
                                application.css, the URL path to it would be
                                http://example.com/application.css
css_dir = "."                <= the directory to look for css files. "." in linux
                                means "the current directory", so this would set you
                                CSS path to app/assets/stylesheets
sass_dir = "."               <= same as above, except for .sass/.scss files
images_dir = "img"           <= images go in app/assets/stylesheets/img
javascripts_dir = "js"       <= javascript go in app/assets/stylesheets/js
                                (seems like a strange place to put them)
output_style = :compressed   <= either to produce .gzip'ed versions of files
                                or to minify them, maybe both - consult docs on this
relative_assets=true         <= relative, as opposed to absolute paths to assets, I think
line_comments = false        <= I think this turns on/off the ability to include comments,
                                or maybe whether the comments are included in the
                                compressed versions of the file. turn it to "true" and
                                compare the assets, as served to the browser, and see
                                what the difference is

答案 2 :(得分:0)

您可以通过从Sublime Text中删除Live Reload插件来解决此问题。

Sublime Text > Preferences > Package Control > Remove Package > Live Reload

对我而言,这是一个很好的解决方案,因为我没有使用Live Reload。 谁使用实时重新加载请关注问题:github