sass编译

sass编译

命令行编译

单文件转换命令css

sass style.scss style.css

单文件监听命令html

sass --watch style.scss:style.css

文件夹监听命令git

sass --watch sassFileDirectory:cssFileDirectory

css文件转成sass/scss文件(在线转换工具css2sassgithub

sass-convert style.css style.sass   
sass-convert style.css style.scss

命令行其余配置选项

运行命令行帮助文档,能够得到全部的配置选项web

sass -h

咱们通常经常使用的有--style--sourcemap--debug-info等。sass

sass --watch style.scss:style.css --style compact sass --watch style.scss:style.css --sourcemap sass --watch style.scss:style.css --style expanded --sourcemap sass --watch style.scss:style.css --debug-info 
  • --style表示解析后的css是什么格式,有四种取值分别为:nestedexpandedcompactcompressed
  • --sourcemap表示开启sourcemap调试。开启sourcemap调试后,会生成一个后缀名为.css.map文件。
  • --debug-info表示开启debug信息,升级到3.3.0以后由于sourcemap更高级,这个debug-info就不太用了。

四种style生成后的css

// nested #main { color: #fff; background-color: #000; } #main p { width: 10em; } .huge { font-size: 10em; font-weight: bold; text-decoration: underline; } // expanded #main { color: #fff; background-color: #000; } #main p { width: 10em; } .huge { font-size: 10em; font-weight: bold; text-decoration: underline; } // compact #main { color: #fff; background-color: #000; } #main p { width: 10em; } .huge { font-size: 10em; font-weight: bold; text-decoration: underline; } // compressed #main{color:#fff;background-color:#000}#main p{width:10em}.huge{font-size:10em;font-weight:bold;text-decoration:underline}

gui编译

这里推荐koala,它是一个优秀的免费编译器,界面清晰简洁,操做起来也很是简单,详细的你们能够移歩到:Less/Sass编译工具,koala使用指南,简单操做以下图:网络

koala compile

编辑器编译

某些高上大的编辑器自己就内置了sass的编译,如webstorm等,而对于sublime text也有相应的插件能够使用:编译保存即编译。若是不清楚你的编辑器是否拥有自动编译的功能,可谷歌百度。app

在线编译

sassmeister提供了在线编译。koa

 

文章内容源于网络webstorm

相关文章
相关标签/搜索