在Heroku上结合和缩小JS / CSS的最佳方式 [英] Best way to combine and minify JS / CSS on Heroku

查看:208
本文介绍了在Heroku上结合和缩小JS / CSS的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,根据这个答案:cache => stylesheet_link_tag javascript_include_tag 上的true 选项在Heroku上不起作用。这是真的?我发现:cache =>真正的偶尔工作,但并不总是(奇怪!)



另外,这里最好的解决方案是什么?理想情况下,它将无缝地组合和缩小所有CSS / JS。 Heroku Asset Packager 声称这样做 - 有更好的选择吗?

解决方案

我在Heroku上使用Jammit。很棒。您可以在本地建立您的资产并登录到heroku。使用

  jammit --force 

当前版本0.5.1在heroku上有问题,但您可以从git://github.com/documentcloud/jammit.git

安装固定版本

如果您使用的是Rails 3,请在您的打包器Gemfile中指定以下内容:

  gemjammit,: git => git://github.com/documentcloud/jammit.git

对于Rails 2. * / p>

  config.gemjammit,:source => git://github.com/documentcloud/jammit.git

好运。


First of all, according to this answer, the :cache => true option on stylesheet_link_tag and javascript_include_tag doesn't work on Heroku. Is this true? I've found :cache => true to work occasionally, but not always (weird!)

Also, what's the best solution here? Ideally it would seamlessly combine and minify all CSS / JS. Heroku Asset Packager claims to do this -- are there better options?

解决方案

I'm using Jammit on Heroku. Works Great. You can locally build your assets and check in to heroku. use

jammit --force

the current version 0.5.1 has issues working on heroku but you can install the fixed version from git://github.com/documentcloud/jammit.git

If you are using Rails 3, specify the below in your bundler Gemfile:

gem "jammit", :git => "git://github.com/documentcloud/jammit.git"

For Rails 2.*

config.gem "jammit", :source => "git://github.com/documentcloud/jammit.git"

Good Luck.

这篇关于在Heroku上结合和缩小JS / CSS的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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