Reputation: 38543
What is the cleanest way to import twitter-bootstrap into rails without any gem?
So far I've been manually copying the css/js files into vendor/assets/javascripts
, vendor/assets/stylesheets
Is there a way to do this without moving the files into separate folders?
Upvotes: 1
Views: 618
Reputation: 38543
I copied bootstrap into lib/bootstrap
I'm using make bootstrap
to compile it, then running a rake task to copy the compiled files into vendor/assets
require 'fileutils'
task :bootme do
compiled_bootstrap = 'lib/bootstrap/bootstrap'
FileUtils.cp_r(compiled_bootstrap + '/css/.', 'vendor/assets/stylesheets/')
FileUtils.cp_r(compiled_bootstrap + '/img/.', 'vendor/assets/images/')
FileUtils.cp_r(compiled_bootstrap + '/js/.', 'vendor/assets/javascripts/')
end
Upvotes: 0
Reputation: 8106
You could all CSS and JS in vendor/assets/twitter-bootstrap
.
Then in app/assets/javascripts/application.js
:
//=require_tree ../../../vendor/assets/twitter-bootstrap
And in your app/assets/stylesheets/application.css
:
*= require ../../../vendor/assets/twitter-bootstrap
For non JS or CSS assets like images to go in non-standard directory, in either config/application.rb
or environment-specific config, you'd use:
# can add more than one path string or regexp(s)
config.assets.precompile += ['../../../vendor/assets/twitter-bootstrap/*.png']
The recommended way is to either use a well-maintained gem for your assets, or continue to put vendor JS and CSS assets in vendor/assets/javascripts
and vendor/assets/stylesheets
, respectively.
Upvotes: 1