LoginSignup
3
1

More than 3 years have passed since last update.

[Rails][bootstrap]css→SCSSへ変更する方法

Posted at

Bootstrapのロジック整理のため投稿です。
CSS→SCSS(Sass)への変更方法についてまとめていきます。

rails new

の直後では、デフォルトでapp/assets/stylesheets/application.cssが読み込まれる仕様になっています。

そこで手順は、以下の流れになりそうです。

①app/assets/stylesheets/application.css を削除
②app/assets/stylesheets/application.scssを作成
③Gemfileにbootstrapを追加→bundle install
④app/assets/stylesheets/application.scssにインポート

具体的に見て行きましょう!

①app/assets/stylesheets/application.css を削除

$ rm app/assets/stylesheets/application.css

②app/assets/stylesheets/application.scssを作成

③Gemfileにbootstrapを追加→bundle install

Gemfile.
  gem 'bootstrap'
$ bundle install

④app/assets/stylesheets/application.scssにインポート

application.scss
@import "bootstrap";
3
1
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
3
1