documentcloud / jammit

Industrial Strength Asset Packaging for Rails
http://documentcloud.github.com/jammit/
MIT License
1.16k stars 197 forks source link

How to prevent jammit in production mode ? #125

Closed gummybears closed 13 years ago

gummybears commented 13 years ago

Hi,

Just starting to use jammit (0.6.0) with Rails (3.0.3) on Ubuntu. On the development machine I ran jammit on my assets. The assets are compressed/gzipped in the directory public/assets. These files are checked into git.

Then I do a deployment to one of my test machines (production mode) where I did not install java. I started the server, and noticed jammit starts. I was a bit surprised. I thought running the jammit on the development server, was enough.

Scenario

Basically what I want to achieve is, that I run jammit on the development machine, do a deployment, and I don't need jammit anymore. No on the fly compression, as the assets are already compressed. And that I don't need any public/javascripts or public/stylesheets directory on the production server and no java.

Then I want to use the less and more gems, put CSS into app/stylesheets and include them into git. The only thing I need to do is to :

I don't think jammit was designed to do this ?, but perhaps more people are looking for something similar.

sosedoff commented 13 years ago

I was looking for the same feature, but i found a perfect solution

By default jammit will inject its routes into application route map. What i do is i setup nginx (or apache) to serve all static files separately, which means after deployment (i use capistrano) i run task assets:pack. All packed files are server as static assets and are not generated on the fly anymore. In this case you dont have to store all this packed files in your SCM.

Hope that helps.

gummybears commented 13 years ago

Do you use the view helpers provided by jammit like include_stylesheets, include_javascripts and config/assets.yml ?

sosedoff commented 13 years ago

Yes, i use the same helpers. But the whole point that the jammit routes are never called because the're intercepted by webserver and thus will be only served as static content bypassing the app.

sosedoff commented 13 years ago

Take a look on this nginx configuration sample i use:

https://gist.github.com/2b720b8b5384e529e191