Best way to combine and minify JS / CSS on Heroku

2019-01-31 19:05发布

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?

8条回答
戒情不戒烟
2楼-- · 2019-01-31 19:25

I haven't tried it on heroku yet, but Sprockets might be good for that. Also, in the past, I've had more luck with

:cache => 'all.css'
:cache => 'all.js'

instead of 'true'

查看更多
甜甜的少女心
3楼-- · 2019-01-31 19:30

GitHub has a good answer for this, and I'm sure you could modify Heroku's deployment scripts to integrate:

http://github.com/blog/551-optimizing-asset-bundling-and-serving-with-rails

查看更多
登录 后发表回答