Tianhe Gao

Hugo 用 Dartsass 替换 Libsass

Hugo 默认使用 Libsass 编译 *.scss 文件,Libsass 已经不再维护了,Sass 官方推荐使用 Dartsass。我的仓库中用到 npm 包,所以通过这一方式安装相关依赖。

netlify.toml 设置:

 1[build]
 2publish = "public"
 3command = """\
 4  mkdir -p /opt/build/repo/node_modules/.bin && \
 5  cp /opt/build/repo/node_modules/sass-embedded-linux-x64/dart-sass-embedded/dart-sass-embedded /opt/build/repo/node_modules/.bin && \
 6  dart-sass-embedded --version && \
 7  pnpm run all \
 8"""
 9
10[context.production.environment]
11  HUGO_VERSION = "0.110.0"
12  NODE_VERSION = "18.12.1"

以上内容并不通用,根据自己情况修改使用。

修改相关模板 themes/tianheg/layouts/partials/style.html

1{{- $options := (dict "transpiler" "dartsass") -}}

参考资料


No notes link to this note

Welcome to tell me your thoughts via "email"
UP