Railsにbootstrapをsassで入れる

May 23, 2015

twbs/bootstrap-sassを使います。

Gemfileに下記のように記述します。

gem ‘bootstrap-sass’, ’~> 3.3.4’

bundle installで導入します。

すでにあるapplication.cssapplication.scssにリネームします。

$ mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss

下記の行をapp/assets/stylesheets/application.scssに追記します。

@import “bootstrap-sprockets”; @import “bootstrap”;

全ての//= requireという部分を削除します。scssを利用する場合は@importを利用するようにします。app/assets/javascripts/application.jsに下記の行を追記します。

//= require bootstrap-sprockets


Profile picture

Written by morizotter who lives and works in Tokyo building useful things. You should follow them on Twitter