rharriso / bower-rails

Bundler-like DSL + rake tasks for Bower on Rails
MIT License
1.46k stars 128 forks source link

Bower-rails should allow custom paths #28

Closed ghost closed 10 years ago

ghost commented 11 years ago

Hi, I like to fill a feature request. I use bower-rails for several days, and I like to use it as main assets dependencies manager for my mini CSS Framework. Unfortunately, bower-rails have some hard-coded restrictions for directories. In my opinion, every tool should allow developers to use it as they want, without restrictions. Many developers have their own preferences for ex. project directory structure.

Bower-rails restricts root directory to {vendor,lib}/assets. This is the first restriction that should be removed, so anyone can set their own root path. This can be useful in many cases, for example if bowler-rails is used with, Sinatra, or used for custom Rack project.

Also, bowler-rails should inherit paths in groups (Jsfile).

Take a look at this example Jsfile:

assets_path '/vendor/assets/javascripts'

group :frameworks do
  js "bootstrap-2.3.2", "bootstrap#2.3.2"
end

IMO, this example Jsfile should create a bootstrap-2.3.2 folder in /vendor/assets/javascripts/frameworks directory, which contains a bootstrap-2.3.2 files directly. Unfortunately, and not intuitively, bower-rails creates a Rails.root/javascripts/vendor/assets/javascripts/bower_components/bootstrap-2.3.2 directory. I consider this as a bug.

SergeyKishenin commented 11 years ago

Thank you for your remark.

Bower-rails restricts root directory to {vendor,lib}/assets as the Rails' convention says:

app/assets - assets specific to your application (custom images, custom javascript, etc.) lib/assets - assets that you wrote but are may be shared across applications (shared icons, javascript, base stylesheet) vendor/assets - assets not specific to you app or written by yocu (Jquery plugins, CSS frameworks, etc)

I guess that current version of bower-rails is designed to be used with Rails (huh, but the name speaks for itself), so we should follow the rules.

In your example of Jsfile the rake task created Rails.root/frameworks/vendor/assets/javascripts/bower_components/bootstrap-2.3.2 directory (not Rails.root/javascripts... as in your example). It is right and there is no bug as the first argument in a group call formally the root directory for all this assets stuff. Then it joins either global assets_path defined in Jsfile or local assets_path for each group (this stuff is described in details here https://github.com/42dev/bower-rails#ruby-dsl-configuration)

So to achieve the result you want, you have to do something like

assets_path '/assets/frameworks'

group :vendor do
  js "bootstrap-2.3.2", "bootstrap#2.3.2"
end

or

group :vendor, assets_path: '/assets/frameworks' do
  js "bootstrap-2.3.2", "bootstrap#2.3.2"
end