Add bower to rails project
Install bower using npm
npm install -g bower
.bowerrc
Create .bowerrc
file at root of your rails app to set the path to your component.
touch .bowerrc
{ "directory": "vendor/assets/components" }
.gitignore
bower_components
Init bower
File bower.json
will be create depend on your answers.
bower init
It should looks like:
{ "name": "project name", "ignore": [ "**/.*", "node_modules", "bower_components", "test", "tests" ], "dependencies": { "bootstrap-fileinput": "latest" # Add libraries that you need here. }, "private": true }
Find more library at https://bower.io/search
Install your libraries
bower install
config/application.rb
config.assets.paths << Rails.root.join('vendor', 'assets', 'components')
Don't forget require .js
and .css
files in application.css
and application.js