Repo that I’m working on: https://gitlab.com/VincentTam/introduction
Branch: staticman
Test site: https://vincenttam.gitlab.io/introduction
I’m trying to add a conditional in a SASS file to optionally load a SASS file assets/sass/_staticman.sass
# assets/sass/style.sass
{{ if .Site.Params.staticman }}
@import "staticman"
{{ end }}
I’ve set that parameter to true
. It gets loaded into the template.
# layouts/partials/head/css.html
{{ $bundleRaw := resources.Get "sass/style.sass" | resources.ExecuteAsTemplate "/css/main.tmp.css" . }}
{{ if .Site.IsServer }}
{{ $cssOpts := (dict "targetPath" "/css/main.css" "enableSourceMap" true ) }}
{{ $bundle := $bundleRaw | toCSS $cssOpts }}
<link rel="stylesheet" href="{{ $bundle.RelPermalink }}" media="screen">
{{ else }}
{{ $cssOpts := (dict "targetPath" "/css/main.css" ) }}
{{ $postCSSOpts := (dict "use" "autoprefixer" ) }}
{{ $bundle := $bundleRaw | toCSS $cssOpts | postCSS $postCSSOpts | minify | fingerprint }}
<link rel="stylesheet" href="{{ $bundle.RelPermalink }}" integrity="{{ $bundle.Data.Integrity }}" crossorigin="anonymous" media="screen">
{{ end }}
It workes fine in local preview.
However, it doesn’t get loaded in GitLab CI’s build:
https://vincenttam.gitlab.io/introduction/css/main.min.66cab924513b4e21e82a3a8bdf4737b1450d809e919f8db8b672e9744d7f2f1f.css
Edit: the above link is no longer valid since I’ve solved this problem and regenerated CSS resources. The problematic generated CSS file in the artifact is downloadable at https://gitlab.com/VincentTam/introduction/-/jobs/258602835/artifacts/file/public/css/main.min.66cab924513b4e21e82a3a8bdf4737b1450d809e919f8db8b672e9744d7f2f1f.css.
The
.modal-close{background-color:#000}
at the end of the generated CSS code actually comes from
# assets/sass/style.sass
{{ $themeStyle := .Site.Params.themeStyle | default "light" }}
@import "{{ $themeStyle }}-style"
I’ve used monachus/hugo
in my GitLab CI config. I’m scratching my head on the reason why the rules for Staticman doesn’t get loaded.