I have these three lines in one of my templates. They work just fine:
{{ $sassOptions := (dict "outputStyle" "compressed" "enableSourceMap" true) -}}
{{ $styles := resources.Get "CSS/all.scss" | resources.ToCSS $sassOptions | fingerprint -}}
<link rel='stylesheet' href='{{ $styles.RelPermalink }}' integrity='{{ $styles.Data.Integrity }}'>
Unfortunately, it took me a bit to get these three lines right. For a while, I accidentally referred to “CSS/main.scss”, which doesn’t exist. The three lines looked like this:
{{ $sassOptions := (dict "outputStyle" "compressed" "enableSourceMap" true) -}}
{{ $styles := resources.Get "CSS/main.scss" | resources.ToCSS $sassOptions | fingerprint -}}
<link rel='stylesheet' href='{{ $styles.RelPermalink }}' integrity='{{ $styles.Data.Integrity }}'>
This gave me the following error message:
ERROR 2020/01/23 19:25:11 Failed to render pages: render of "home" failed: "/Users/comatoast/Projects/hugo-boilerplate/layouts/index.html:7:59": execute of template failed: template: index.html:7:59: executing "index.html" at <resources.ToCSS>: error calling ToCSS: type map[string]interface {} not supported in Resource transformations
…which made me think I’d screwed up by passing $sassOptions
to resources.ToCSS
. This was…not my problem.
Would it be possible to improve the error message for resources.ToCSS
?