Tip:Sass是一种"CSS预处理器",使用Sass可以有效提高CSS的开发效率,Compass是一个使用了Sass的库,封装了一系列有用的模块和模板,Compass是用Ruby语言开发的,因此安装它以前,必须安装Rubycss
默认状况下。macOS是默认安装好Rubygit
在命令行下能够直接经过如下命令,确认系统 Ruby 的版本信息:github
$ ruby --version ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
可是,因为默认的 Ruby 安装在 /System 目录下,对平常的开发、维护都带来许多不便。sass
推荐使用 homebrew 来安装、管理 Ruby 的版本ruby
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Tip:刚开始使用了一下命令报错,注意要进入ruby安装所在的目录/usr/bin/ruby执行命令curl
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" curl: (22) The requested URL returned error: 404 Not Found
brew update brew install ruby
$ ruby --version
gem install compass
compass create my-project
安装成功的提示url
directory my-project/ directory my-project/sass/ directory my-project/stylesheets/ create my-project/config.rb create my-project/sass/screen.scss create my-project/sass/print.scss create my-project/sass/ie.scss write my-project/stylesheets/ie.css write my-project/stylesheets/print.css write my-project/stylesheets/screen.css ********************************************************************* Congratulations! Your compass project has been created. You may now add and edit sass stylesheets in the sass subdirectory of your project.
sass目录中就是对应的源文件目录,当咱们在该目录下进行代码的编写,经过如下命令来进行编译命令行
$ compass compile