If you haven’t heard about bower, you must have been living under a rock. It’s now the de facto front-end package manager for the web. Almost (if not all) frontend libraries are now created to be compatible with bower (a bower package). Using bower, you can search, list, install, uninstall, update and manage dependencies for your projects.
(If you want to play more with nodejs, I recommend you to try nvm and use it to manage your nodejs installations)
After that, create a
.bowerrc file with the following contents at the root of the project folder to change default location for bower’s packages from
./vendor/bower_components (you can choose another folder if you want):
bower init to generate a
bower.json for your project. Using this file, You can manage your project information and dependencies:
Then, you must add the bower’s package folder to Rails’ Asset Pipeline by editing the
config/application.rb as following:
Now, bower is already at your command. You can search for packages, add them in dependencies section of
bower.json file and
bower install in your project’s root folder to install all of them. Alternatively, you can install each package separately as following:
To use bower packages, just add them to your asset manifest files like any other frontend library. For example:
You can also list your installed bower packages, update or remove them
In my personal opinion, bower is really a great tool, it helps manage frontend libraries much more easier. Combine with Rails’ Asset Pipeline, it makes a powerful tool to conquer any kind of frontend related projects.