<div dir="ltr">I'm struggling with getting asset deployment to work after upgrading a few of our apps to Rails 4. I have two main problems:<div><br class="">* We cannot reference images/fonts from stylesheets<br></div>
<div>* Our CSS/JS is no longer being minified in production</div><div><br></div><div>The first one is because Rails no longer generates unversioned filenames in public/assets, so you need to have</div><div><br></div><div>
    body {</div><div>      background: url(/assets/cat-abc123def456.jpg);</div><div>    }</div><div><br></div><div>in your stylesheet rather than</div><div><br></div><div>    body {</div><div>      background: url(/assets/cat.jpg);</div>
<div>    }</div><div><br></div><div>Of course, the latter works in development but not in production after precompiling the assets. So, we need to know how to get those version numbers into the CSS, since Rails does not rewrite these references by default while precompiling assets.</div>
<div><br></div><div>Second, our CSS is not being minified, and we have no idea why. If you clone <a href="https://github.com/jcoglan/rails_assets">https://github.com/jcoglan/rails_assets</a>, and run:</div><div><br></div>
<div>    $ bundle exec rake assets:precompile</div><div><br></div><div>then it does not minify the code in public/assets, which we assumed was because config/environments/development.rb sets config.assets.debug = true. If you compile in production:</div>
<div><br></div><div>    $ RAILS_ENV=production bundle exec rake assets:precompile</div><div><br></div><div>then it does minify the CSS. So, we figured there must be a config difference and that would explain why our code is not being minified in our production apps that have been upgraded from Rails 3 to 4. So, I deleted all the code from config/environments/{development,production}.rb and it still does the same thing: no minification in development mode, and minified code in production. So it doesn't seem like a config thing -- is this difference baked in Rails? What am I doing wrong? Why would our production apps not be minifying their CSS?<br clear="all">
<div><br></div>-- <br>James Coglan<br><a href="http://jcoglan.com">http://jcoglan.com</a><br>+44 (0) 7771512510</div></div>