Open jloh opened 1 month ago
Anything I can do to help debug?
Not really. I understand the what, just not the how. This feature is fairly straight forward for regular hugo
builds, but I guess it needs some better testing on the server/rebuild side.
{{- $tailwind = $tailwind | resources.Fingerprint "sha512" | resources.PostProcess -}}
I guess the main reason I have not seen this in my setups is that I have constructs similar to this:
That is, in your setup, the defer block will change whenever the stylesheet/fingerprint changes, which (in my head) has several drawbacks.
My reasoning for using defer was I found using Tailwind's purging resulted in weird builds during development where it often would require a full restart of the dev server to get classes that were previously missing.
Changing my defer
template over to the one you link above (ie no fingerprinting) seems to result in a more stable build though!
Just realised this is because it stopped using resources.PostProcess
so I think doesn't defer?
I've never had problems with Hugo generating CSS on a live build (ie just hugo
command), its purely been a problem for me with the development server interestingly.
{{- $tailwind = $tailwind | resources.Fingerprint "sha512" | resources.PostProcess -}}
Yea, OK, that doesn't work ... well. templates.Defer
is replacing resources.PostProcess
so having both will give undefined results. It should not crash, so I suspect that's a real issue, but you should remove resources.PostProcess.
I have had some browser live reload issues myself lately (one issue seem to be a newly introduced bug in Chrome). I have pushed a reimplementation (with better info loggin) to Hugo's main branch, but haven't released yet, will soon.
Thanks Bep, I've removed resources.PostProcess
and everything is working fine now! I ended up moving it in to my baseof.html
like your example then copying the rest of that. Final code looked like this:
{{ with (templates.Defer (dict "key" "global")) -}}
{{- $options := (dict "inlineImports" true ) -}}
{{- $tailwind := resources.Get "css/main.css" | resources.PostCSS $options -}}
{{- if hugo.IsDevelopment -}}
<link rel="stylesheet" href="{{ $tailwind.RelPermalink }}" />
{{- else -}}
{{- $tailwind = $tailwind | resources.Fingerprint "sha512" -}}
<link
rel="stylesheet"
href="{{ $tailwind.RelPermalink }}"
integrity="{{ $tailwind.Data.Integrity }}"
crossorigin="anonymous"
/>
{{- end -}}
{{- end }}
Since moving to the new format I'm now getting a slightly new error:
Change detected, rebuilding site (#1).
2024-07-14 00:06:46.877 +1000
Template changed /_default/_markup/render-link.html
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Total in 37 ms
ERROR Failed to render "/posts/": "/Users/james/code/github/jloh/blog/layouts/_default/baseof.html:1:1": parse failed: html/template: cannot Parse after Execute
Happy to open a new issue if thats easier.
Happy to open a new issue if thats easier.
No, it's most likely the same issue, but with a more clear text ...
But I have note been able to reproduce it (I have had a bash script doing some edits in a loop for the last hour ...), but I guess it will eventually happen.
What version of Hugo are you using (
hugo version
)?I normally use the extended version but currently seem to just have the standard version installed.
Does this issue reproduce with the latest release?
Yes
I'm currently trying the new deferred templates since I've historically found when changing my CSS classes Hugo can sometimes generate an outdated Tailwind build. Every now and then though my dev server panics and crashes with the below error:
This is the result of me editing a post on the site.
My deferred template looks like this:
Which is included in my
baseof.html
via{{ partialCached "head/css" . }}
. I've tried moving it to justbaseof.html
but it crashes randomly doing that as well.Anything I can do to help debug?