Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding bowerify gem to fix the issue with relative assets paths in bower components #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ asset "secret_logic", "1.0.0", git: "[email protected]:initech/secret_logic"
# get from a github repo
asset "secret_logic", "1.0.0", github: "initech/secret_logic"

# get a specific revision from a git endpoint
# get a specific revision from a git endpoint
asset "secret_logic", github: "initech/secret_logic", ref: '0adff'
```

Expand Down Expand Up @@ -171,10 +171,6 @@ will ignore the `directory` property and instead will use the automatically gene

[Bower](https://github.com/bower/bower) should be installed using npm. Bower can be installed globally (with `$ npm install -g bower`) or in `node_modules` in the root directory of your project.

##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.

Remember that you should have [bower installed](#bower-installation) either locally in your project or on a remote server.

##Bower Main Files
Expand Down
4 changes: 3 additions & 1 deletion bower-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.license = 'MIT'

s.add_dependency "bowerify"

s.add_development_dependency "rspec"
s.add_development_dependency "rake"
s.add_development_dependency "coveralls"
end
end
2 changes: 2 additions & 0 deletions lib/bower-rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Railtie < Rails::Railtie
["lib", "vendor"].each do |dir|
app.config.assets.paths << Rails.root.join(dir, 'assets', 'bower_components')
end

app.config.bower_components_path = Rails.root.join('lib', 'assets', 'bower_components')
end
end

Expand Down