LoginSignup
9
9

More than 5 years have passed since last update.

bootstrap-sassのためにSass、Compassの導入をした

Last updated at Posted at 2015-02-08

Bootstrapを基に独自のCSSを作成したい時に、bootstrap-sassという便利なものを発見したので早速導入した。 導入に何がインストールされたのかを記録するためにもこの記事を書いている。

以下のURLに載っている通り、インストールを行った。Rails不要なタイプでやっている。
https://github.com/twbs/bootstrap-sass#b-compass-without-rails

bootstrap-sassインストール
$ sudo gem install bootstrap-sass
Fetching: sass-3.4.11.gem (100%)
Successfully installed sass-3.4.11
Fetching: execjs-2.3.0.gem (100%)
Successfully installed execjs-2.3.0
Fetching: autoprefixer-rails-5.1.5.gem (100%)
Successfully installed autoprefixer-rails-5.1.5
Fetching: bootstrap-sass-3.3.3.gem (100%)
Successfully installed bootstrap-sass-3.3.3
Parsing documentation for sass-3.4.11
Installing ri documentation for sass-3.4.11
Parsing documentation for execjs-2.3.0
Installing ri documentation for execjs-2.3.0
Parsing documentation for autoprefixer-rails-5.1.5
Installing ri documentation for autoprefixer-rails-5.1.5
Parsing documentation for bootstrap-sass-3.3.3
Installing ri documentation for bootstrap-sass-3.3.3
4 gems installed
Compassインストール
$ sudo gem install compass
Fetching: multi_json-1.10.1.gem (100%)
Successfully installed multi_json-1.10.1
Fetching: compass-core-1.0.3.gem (100%)
Successfully installed compass-core-1.0.3
Fetching: compass-import-once-1.0.5.gem (100%)
Successfully installed compass-import-once-1.0.5
Fetching: chunky_png-1.3.3.gem (100%)
Successfully installed chunky_png-1.3.3
Fetching: rb-fsevent-0.9.4.gem (100%)
Successfully installed rb-fsevent-0.9.4
Fetching: ffi-1.9.6.gem (100%)
Building native extensions.  This could take a while...
Successfully installed ffi-1.9.6
Fetching: rb-inotify-0.9.5.gem (100%)
Successfully installed rb-inotify-0.9.5
Fetching: compass-1.0.3.gem (100%)
    Compass is charityware. If you love it, please donate on our behalf at http://umdf.org/compass Thanks!
Successfully installed compass-1.0.3
Parsing documentation for multi_json-1.10.1
Installing ri documentation for multi_json-1.10.1
Parsing documentation for compass-core-1.0.3
Installing ri documentation for compass-core-1.0.3
Parsing documentation for compass-import-once-1.0.5
Installing ri documentation for compass-import-once-1.0.5
Parsing documentation for chunky_png-1.3.3
Installing ri documentation for chunky_png-1.3.3
Parsing documentation for rb-fsevent-0.9.4
Installing ri documentation for rb-fsevent-0.9.4
Parsing documentation for ffi-1.9.6
Installing ri documentation for ffi-1.9.6
Parsing documentation for rb-inotify-0.9.5
Installing ri documentation for rb-inotify-0.9.5
Parsing documentation for compass-1.0.3
Installing ri documentation for compass-1.0.3
8 gems installed
Compassで新規プロジェクト作成
$ compass create my-new-project -r bootstrap-sass --using bootstrap
directory my-new-project/
directory my-new-project/fonts/bootstrap/
directory my-new-project/javascripts/
directory my-new-project/javascripts/bootstrap/
directory my-new-project/sass/
directory my-new-project/stylesheets/
   create my-new-project/config.rb
   create my-new-project/sass/styles.scss
   create my-new-project/sass/_bootstrap-variables.scss
   create my-new-project/javascripts/bootstrap/affix.js
   create my-new-project/javascripts/bootstrap/alert.js
   create my-new-project/javascripts/bootstrap/button.js
   create my-new-project/javascripts/bootstrap/carousel.js
   create my-new-project/javascripts/bootstrap/collapse.js
   create my-new-project/javascripts/bootstrap/dropdown.js
   create my-new-project/javascripts/bootstrap/modal.js
   create my-new-project/javascripts/bootstrap/popover.js
   create my-new-project/javascripts/bootstrap/scrollspy.js
   create my-new-project/javascripts/bootstrap/tab.js
   create my-new-project/javascripts/bootstrap/tooltip.js
   create my-new-project/javascripts/bootstrap/transition.js
   create my-new-project/javascripts/bootstrap-sprockets.js
   create my-new-project/javascripts/bootstrap.js
   create my-new-project/javascripts/bootstrap.min.js
   create my-new-project/fonts/bootstrap/glyphicons-halflings-regular.eot
   create my-new-project/fonts/bootstrap/glyphicons-halflings-regular.svg
   create my-new-project/fonts/bootstrap/glyphicons-halflings-regular.ttf
   create my-new-project/fonts/bootstrap/glyphicons-halflings-regular.woff
   create my-new-project/fonts/bootstrap/glyphicons-halflings-regular.woff2
    write my-new-project/stylesheets/styles.css

*********************************************************************
Congratulations! Your compass project has been created.

You may now add and edit sass stylesheets in the sass subdirectory of your project.

Sass files beginning with an underscore are called partials and won't be
compiled to CSS, but they can be imported into other sass stylesheets.

You can configure your project by editing the config.rb configuration file.

You must compile your sass stylesheets into CSS when they change.
This can be done in one of the following ways:
  1. To compile on demand:
     compass compile [path/to/project]
  2. To monitor your project for changes and automatically recompile:
     compass watch [path/to/project]

More Resources:
  * Website: http://compass-style.org/
  * Sass: http://sass-lang.com
  * Community: http://groups.google.com/group/compass-users/


To import your new stylesheets add the following lines of HTML (or equivalent) to your webpage:
<head>
  <link href="/stylesheets/styles.css" rel="stylesheet" type="text/css" />
</head>

その後は、compass watch [プロジェクトのパス]でSassファイルを監視して、セーブされたらCSSにコンパイルするようにしておく。

参考

twbs/bootstrap-sass
https://github.com/twbs/bootstrap-sass#b-compass-without-rails
CSSの常識が変わる!「Compass」の基礎から応用まで! | 株式会社LIG
http://liginc.co.jp/designer/archives/11623

9
9
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
9
9