Jekyll Sass Invalid GBK character 解决办法

问题

 Incremental build: disabled. Enable with --incremental
      Generating...
  Conversion error: Jekyll::Converters::Scss encountered an error while converting 'assets/main.scss':
                    Invalid GBK character "\xE8" on line 19
jekyll 3.8.1 | Error:  Invalid GBK character "\xE8" on line 19

在 Windows 10 下 bundle exec jekyll serve 来编译站点时,Sass转换出错。

软件版本

  • Windows 10
  • Windows 命令处理程序
  • rubyinstaller-devkit-2.4.4-2-x64
  • jekyll 3.8.1

解决

此问题与 windows 下的中文编码相关。直接找到 sass 的源文件加入 utf-8 设置即可。

操作步骤:

  1. 找到自己的 sass 工具的 engine.rb 源码位置并打开,例如笔者默认安装位置 "C:\Ruby24-x64\lib\ruby\gems\2.4.0\gems\sass-3.5.6\lib\sass\engine.rb"
  2. 在 require 代码后加入 utf-8 设置代码

    Encoding.default_external = Encoding.find('utf-8')

    如图:

    代码加入位置

  3. 重新运行 bundle exec jekyll serve 命令。Sass编码问题不再出现。

参考

猜你喜欢

转载自blog.csdn.net/u013614126/article/details/81626558