GithubHelp home page GithubHelp logo

joefiorini / bower Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stve/bower

0.0 2.0 0.0 487 KB

Bower integration for your ruby/rails apps.

License: MIT License

Ruby 96.98% JavaScript 3.02%

bower's Introduction

Bower

Gem Version Build Status

Bower integration for your ruby apps.

Note: Bower's development is in a state of flux as they migrate to new conventions. Development of this library will stay in lock-step with the Bower spec, but no new releases will occur until the spec stabilizes and Sprockets support is complete as well.

Usage with Sprockets

Rails

Add bower to your application's Gemfile:

gem 'bower'

Rails 4 ships with an updated version of Sprockets that supports bower's bower.json file. If you are running, Rails 3, then you need to require Sprockets 2.2.2.backport1:

gem 'sprockets', '2.2.2.backport1'

The gem includes a generator that sets up your project:

rails generate bower:install

This will install a .bowerrc file to your project's root directory that looks like this:

{
  "directory"  : "bower_components",
  "json"       : "bower.json",
  "endpoint"   : "https://bower.herokuapp.com",
  "searchpath" : []
}

Add your dependencies to bower.json then use bower (bower install, etc.) as you would in any other project.

Non-Rails Projects

While offering less capability than when used in Rails' asset pipeline, you can still use the bower gem in a non-Rails project. Just require the gem and append the corresponding directory to Sprocket's load path:

require 'sprockets'
require 'bower'

environment = Sprockets::Environment.new
environment.append_path Bower.environment.directory

How this gem differs from other techniques

For Rails apps, integrating bower components into lib/assets and/or vendor/assets seems like the wrong approach. Since bower can support multiple searchpaths, the need to make a distinction between external dependencies and frameworks does not exist. It can all be managed in once place. This gem takes a more opinionated approach and installs components to bower_components/ in your project's root by default. You can always change it to another location.

If this approach isn't to your liking, you may want to take a look at bower-rails.

TODO

When used with Sprockets, you still need to use a require directive in order to require a component's files. This seems like something that should just work.

Contributing

Pull requests welcome: fork, make a topic branch, commit (squash when possible) with tests and I'll happily consider merging your contributions.

Copyright

Copyright (c) 2013 Steve Agalloco. See LICENSE for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.