There are some times where I add some JavaScript libraries as submodules to my project:
git submodule add git://... resources/project_name
cd assets/stylesheets/my_controller
ln -s ../../../resources/project_name/css/project_name.css
cd -
cd assets/images/my_controller
ln -s ../../../resources/project_name/img/sprite.png
While this works great in development mode, I have to create more
symbolic links to make it work under production as well.
Here is why. Under development mode the css is written like this:
.some-class { background: url(sprite.png) } /* relative URL */
Under development this file path is
“/assets/my_controller/project_name.css” while the image is located at “/assets/my_controller/sprite.png”.
When assets:precompile is run, project_name.css no longer exists and
the rule is appended to application.css, but the relative URL is not rewritten to ‘my_controller/sprite.png’ or ‘/assets/my_controller/sprite.png’.
The Grails Resources plugin supports URL rewriting for dealing with
this kind of issue that happens when using an asset pipeline:
http://grails.org/plugin/resources http://grails-plugins.github.com/grails-resources/ (sorry, documentation is not that good, but it works this way, I promiss)
It is not a good experience to have your application working under
development and stopping working under production due to things like this.
Also, I like the idea of grouping my assets in sub-directories.
Shouldn't the Rails assets generator support URL rewriting in CSS
for supporting such an organized tree both in development and production environment out of the box?
Am I missing something?
Best,
Rodrigo.