LoginSignup
67
76

More than 5 years have passed since last update.

Rails bootstrapの導入 sassのススメ

Posted at

「rails bootstrap」とかでググるとbootstrapの導入をlessでやる記事ばかり出てきました。
lessが好きな方が多いか分からないですが、sassで導入したほうが楽なのでは?と思いました。
sassでstyle書くことが多いと思うので(←ただの主観)、わざわざlessを導入する必要はないと思うのです。

sassを使う僕としてはsassがいいです。
やり方、lessもsassも書いておきます。お好みのほうをお使い下さい。

less

Gemfile
gem 'therubyracer'
gem 'less-rails'
gem 'twitter-bootstrap-rails'
$ budle install
$ rails g bootstrap:install

application.css と application.js に 自動的にbootstrapの記述が追加されています。
https://github.com/seyhunak/twitter-bootstrap-rails

sass

Gemfile
gem 'bootstrap-sass'
gem 'sass-rails'
$ bundle install

application.css -> application.scss

app/assets/stylesheets/application.scss
@import "bootstrap-sprockets";
@import "bootstrap";
app/assets/javascripts/application.js
//= require jquery
//= require bootstrap-sprockets

以上で十分ですが、こちらのカスタマイズの記事も参考になると思います。
全部はいらないよね?bootstrap-sassをカスタマイズして使う方法

67
76
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
67
76