sass 編譯 可能會(huì)出現(xiàn)兩種情況:
一、手動(dòng)編譯
比如編譯的文件內(nèi)有 包含中文 例如:
@charset "utf-8"
/* 出現(xiàn)中文的注釋 */
$fontFamily: '微軟雅黑';
*{
font-family:$fontFamily;
}
編譯:
報(bào)錯(cuò) :error src/sass/common.scss (Line 4: Invalid GBK character "\xE5")
解決方案:
找到此文件C:\Ruby23-x64\lib\ruby\gems\2.3.0\gems\sass-3.4.22\lib\sass\engine.rb
在require XXX 下一行 添加 Encoding.default_external = Encoding.find('UTF-8') 即可
二、gulp下的watch
報(bào)錯(cuò): Encoding::CompatibilityError: incompatible character encodings: GBK and UTF-8 Use --trace for backtrace.
出現(xiàn)此類錯(cuò)誤時(shí) 檢查下路徑是否出現(xiàn)中文。
總結(jié)
總結(jié)一下:
- sass手動(dòng)編譯亂碼:在C:\Ruby23-x64\lib\ruby\gems\2.3.0\gems\sass-3.4.22\lib\sass\engine.rb的所有require后加一句 Encoding.default_external = Encoding.find('utf-8')。
- watch編譯亂碼:watch編譯的路徑不能有中文。