middleman/middleman-sprockets — pull request #57 by dg-vrnetze (2014-07-24 08:41:25+00:00)
Title: Wrong output directory is chosen if bower components includes javascript AND images etc.

If you want to use `bower` + `sprockets` with `middleman`, components are placed in wrong output directories if your bower-package contains different file types: Images go to `/javascripts`or javascript files go to `/images`. It depends on the order of the `import_asset`-method-calls.

Example:

Given a `config.rb`with

*config.rb*:

```ruby
set :css_dir, 'stylesheets'
set :js_dir, 'javascripts'
set :images_dir, 'images'
sprockets.append_path File.join(root, 'vendor/assets/components')
```
And Your bower package contains
* Javascript files
* Images

If you import the javascripts assets first, all other assets - images etc. - are place in `javascripts` directory.

*config.rb (continued)*:

```ruby
sprockets.import_asset 'lightbox2/js/lightbox.js'
sprockets.import_asset 'lightbox2/img/close.png'
```
In `lib/middleman-sprockets/extension.rb` "memoization" is used in a loop which is responsible for this behaviour. This PR fixes this. Only if the `load_path` ends with "images", "javascripts" etc. it is used for later assets. If your path does not end with "images", "javascripts" etc. it is `nil` and the output_dir will be determined for each asset.

Feedback on this is highly welcome. :-)

Cheers,
dg