Compass/compass-rails — Issue #5: Unable to append to sprite_load_path
Author: exviva
Created: 2012-02-02 10:18:07+00:00
State: open

I'm having trouble modifying the `sprite_load_path` config option.

I've tried to append an element to `Compass.configuration.sprite_load_path` in several ways, but when `SpriteImporter#files` is called, the `Compass.configuration.sprite_load_path` is always the original 1-element array.

I'm actually developing a Rails plugin, and want to add its `app/assets/images` directory to the `sprite_load_path`. I've tried doing that in the plugin's `config/initializers/compass.rb`:

```ruby
Rails.application.config.compass.sprite_load_path << File.expand_path('../../../app/assets/images', __FILE__)
```

I've tried moving this initializer file to the Rails application's `config/initializers` directory.

Then, I've modified the application's `config/application.rb` and added the following to the class:

```ruby
config.compass.sprite_load_path << File.expand_path('../../../../my-plugin/app/assets/images', __FILE__)
```

I can confirm that the configuration is modified in each case right after I modify it (inspecting `Compass.configuration.sprite_load_path.to_a` shows my desired second path).

It seems that the original `Compass.configuration` object and the one used inside `SpriteImporter#files` are two different objects (I inspected their `object_id`s). I could not figure out how the `Compass.configuration` object gets replaced after my initialization.

Can you help me out somehow? How can I modify this setting from within the plugin?

Maybe an even better option would be to automatically append all `assets/images` paths of all Rails engines and plugins?