I work with a team where we use bower packages in the
vendor/assets/javascripts
. Nothing to out of the ordinary, but to compile
them for production we use the following block in our config/application.rb
:
|
All was well with this up until a package was added that had a bower.json
file
in it. The package in our case was requirejs-plugins
. After adding this
package in, during an asset compile we were greated with the following error:
|
When you look in vendor/assets/javascripts/requirejs-plugins
you can
clearly see there is a bower.json
file, so what is the deal? It turns out
Sprockets is to blame for this one, at least partially. To better explain I’ll
include the code in question; which was 2.12.3
as of this writing.
|
Wow, what is going on here?? Well it turns out this is trying to resolve asset
files for you. It has some pretty good smarts to it; however, when you pass it
a bower.json
file it attempts to match any assets defined in it that end in
.json
. This is where the the problem happens… there isn’t a .json
file
defined in the bower file.
To fix this I essentially had to catch the exception being raised in the do block:
|
This isn’t the best solution and I hope to do a touch of refactoring of this
over the weekend to make that Sprockets::resolve
method a little better.