sass的安装

  1. sass基于Ruby语言开发而成,因此安装sass前需要安装Ruby
    下载地址: https://rubyinstaller.org/downloads/
    注:安装过程中请注意勾选Add Ruby executables to your PATH添加到系统的环境变量.(也可以把D:\ToolSofts\Ruby23\bin自己的路径添加到环境变量中)
  2. 安装完成后测试安装有没有成功
ruby - v
//如安装成功会打印
ruby 2.2.2p95 (2015-04-13 revision 50295) [i386-mingw32]
  1. Ruby自带一个叫做RubyGems的系统,用来安装基于Ruby的软件.
//1.删除原gem源
gem sources --remove https://rubygems.org/
//2.添加国内源
gem sources -a http://gems.ruby-china.com/--------------(2019.7.7测试成功)
//3.测试是否替换成功
gem sources -l
//成功打印如下结果
*** CURRENT SOURCES ***

http://gems.ruby-china.com/
//如果没有成功就去找其它可用的源
//4.安装sass
gem install sass
//5.安装compass
gem install compass
//6.安装成功测试
sass -v
结果>>Sass 3.x.x (Selective Steve)
compass -v
结果>>
Compass 1.0.3 (Polaris)
Copyright (c) 2008-2019 Chris Eppstein
Released under the MIT License.
Compass is charityware.
Please make a tax deductable donation for a worthy cause: http://umdf.org/compass

  1. 其它常用命令
  • 更新
  gem update sass
  • 查看Sass版本
  sass -v
  • 查看sass帮助
  sass -h

编译sass

命令行编译

  1. 单文件转换命令
  sass input.scss output.css
  1. 单文件监听命令
  sass --watch input.scss:output.css
  1. 如果有很多的sass文件的目录,也可以监听整个目录
  sass -watch app/sass:public/stylesheets

命令行编译配置选项

  1. 编译格式
  sass --watch input.scss:output.css --style compact
  1. 编译添加调试map
  sass --watch input.scss:output.css --sourcemap
  1. 选择编译格式并添加调试map
  sass --watch input.scss:output.css --style expanded --sourcemap
  1. 开启debug信息
  sass --watch input.scss:output.css --debug-info

四种编译排版

//未编译样式
.box {
  width: 300px;
  height: 400px;
  &-title {
    height: 30px;
    line-height: 30px;
  }
}
  1. nested编译排版格式
/*命令行内容*/
sass style.scss:style.css --style nested

/*编译过后样式*/
.box {
  width: 300px;
  height: 400px; }
  .box-title {
    height: 30px;
    line-height: 30px; }
  1. expanded 编译排版格式
/*命令行内容*/
sass style.scss:style.css --style expanded

/*编译过后样式*/
.box {
  width: 300px;
  height: 400px;
}
.box-title {
  height: 30px;
  line-height: 30px;
}
  1. compact 编译排版格式
/*命令行内容*/
sass style.scss:style.css --style compact

/*编译过后样式*/
.box { width: 300px; height: 400px; }
.box-title { height: 30px; line-height: 30px; }
  1. compressed 编译排版格式
/*命令行内容*/
sass style.scss:style.css --style compressed

/*编译过后样式*/
.box{width:300px;height:400px}.box-title{height:30px;line-height:30px}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值