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

相關文章
相關標籤/搜索