Tom*_*man 29 ruby-on-rails asset-management heroku minify
首先,根据这个答案,:cache => true
选项上stylesheet_link_tag
和javascript_include_tag
不适用于Heroku.这是真的?我发现:cache => true
偶尔会工作,但并不总是(很奇怪!)
另外,这里最好的解决方案是什么?理想情况下,它可以无缝地组合和缩小所有CSS/JS.Heroku Asset Packager声称这样做 - 有更好的选择吗?
Gre*_*reg 23
我在Heroku上使用Jammit.效果很好.您可以在本地构建您的资产并登记到heroku.使用
jammit --force
Run Code Online (Sandbox Code Playgroud)
当前版本0.5.1在heroku上有问题,但您可以从git://github.com/documentcloud/jammit.git安装修复版本
如果您使用的是Rails 3,请在捆绑器Gemfile中指定以下内容:
gem "jammit", :git => "git://github.com/documentcloud/jammit.git"
Run Code Online (Sandbox Code Playgroud)
对于Rails 2.*
config.gem "jammit", :source => "git://github.com/documentcloud/jammit.git"
Run Code Online (Sandbox Code Playgroud)
祝好运.
我发现添加一个git预提交钩子来编译和打包资产,然后将它们添加到当前提交在这种情况下派上用场.
我使用Jammit看起来像这样(in .git/hooks/pre-commit
):
jammit
rake barista:brew
git add public/assets/*
git add public/javascripts/*
Run Code Online (Sandbox Code Playgroud)
像这样,您的所有资产都将为您打包,您不必再担心它了.
我还没有在heroku 上尝试过,但Sprockets可能比较适合。另外,在过去,我有更多的运气
:cache => 'all.css'
:cache => 'all.js'
Run Code Online (Sandbox Code Playgroud)
而不是“真实”