README.md in bower-rails-0.7.1 vs README.md in bower-rails-0.7.2
- old
+ new
@@ -20,11 +20,11 @@
**Install**
in Gemfile
``` Ruby
- gem "bower-rails", "~> 0.7.1"
+ gem "bower-rails", "~> 0.7.2"
```
##JSON configuration
Bower-rails now supports the standard [bower package](https://github.com/bower/bower#defining-a-package) format out-of-the-box. Simply place your bower.json file the Rails root directory to start. Using the standard format will default all bower components to be installed under the `vendor` directory.
@@ -73,11 +73,18 @@
``` ruby
# Puts to ./vendor/assets/bower_components
asset "backbone"
-asset "moment"
+asset "moment", "2.0.0" # get exactly version 2.0.0
+asset "secret_styles", "git@github.com:initech/secret_styles" # get from a git repo
+
+# get from a git repo using the tag 1.0.0
+asset "secret_logic", "1.0.0", git: "git@github.com:initech/secret_logic"
+
+# get from a github repo
+asset "secret_logic", "1.0.0", github: "initech/secret_logic"
```
But the default value can be overridden by `assets_path` method:
``` ruby
@@ -93,11 +100,11 @@
``` ruby
assets_path "assets/javascript"
# Puts files under ./vendor/assets/js/bower_components
group :vendor, :assets_path => "assets/js" do
- asset "jquery" # Assummes it's latests
+ asset "jquery" # Defaults to 'latest'
asset "backbone", "1.1.1"
end
# Puts files under ./lib/assets/javascript/bower_components
group :lib do
@@ -106,21 +113,52 @@
end
```
NOTE: Available groups are `:lib` and `:vendor`. Others are not allowed according to the Rails convention.
NOTE: All the assets should be stored in `/assets` subdirectory so putting it under `./vendor/js` directory is unavailable
+##Configuration
+
+Change options in your `config/initializers/bower_rails.rb`:
+
+``` ruby
+BowerRails.configure do |bower_rails|
+ # By default options are false
+ bower_rails.resolve_before_precompile = true # invokes rake bower:resolve before precompilation
+ bower_rails.clean_before_precompile = true # invokes rake bower:clean before precompilation
+end
+```
+
+If you are using Rails version < 4.0.0 then you are to require `bower_rails.rb` initializer manually in `application.rb`:
+
+```ruby
+module YourAppName
+ class Application < Rails::Application
+ require "#{Rails.root}/config/initializers/bower_rails.rb"
+ ...
+ end
+end
+```
+
+By default this line is added while running the generator.
+
##Rake tasks
Once you are done with `bower.json` or `Bowerfile` you can run
* `rake bower:install` to install js components
-* `rake bower:install:force` to install with force option
* `rake bower:update` to update js components
* `rake bower:update:prune` to update components and uninstall extraneous packages
* `rake bower:list` to list all packages
+* `rake bower:clean` to remove all files not listed as [main files](#bower-main-files) (if specified)
* `rake bower:resolve` to resolve [relative asset paths](#relative-asset-paths) in components
+If you'd like to pass any bower CLI options to a rake task, like `-f`, `-j`, you can simply do:
+
+```bash
+rake bower:install['-f']
+```
+
##Bower Configuration
If you provide a `.bowerrc` in the rails project root, bower-rails will use it for bower configuration.
Some .bowerrc options are not supported: `directory`, `cwd`, and `interactive`. Bower-rails
will ignore the `directory` property and instead will use the automatically generated asset path.
@@ -131,14 +169,10 @@
##Relative asset paths
Some bower components (eg. [Bootstrap](https://github.com/twbs/bootstrap/blob/0016c17f9307bc71fc96d8d4680a9c861f137cae/dist/css/bootstrap.css#L2263)) have relative urls in the CSS files for imports, images, etc. Rails prefers using [helper methods](http://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets) for linking to assets within CSS. Relative paths can cause issues when assets are precompiled for production.
-If you would like the bower assets to be reinstalled with the relative paths on every deploy, provide an option for `bower-rails` so it do it automatically before the `rake assets:precompile` task is run:
-
-``` ruby
-BowerRails.configure do |bower_rails|
- # By default this option is false
- bower_rails.resolve_before_precompile = true
-end
-```
Remember that you should have [bower installed](#bower-installation) either locally in your project or on a remote server.
+
+##Bower Main Files
+
+Each bower component should follow the [bower.json spec](https://github.com/bower/bower.json-spec) which designates a recommended `main` directive that lists the primary files of that component. You may choose to reference these files if you are using the asset pipeline, in which case other extraneous includes of the bower component are not needed. The `rake bower:clean` task removes every file that isn't listed in the `main` directive, if the component specifies a `main` directive. Otherwise, the library will remain as bower installed it.