feat: delay PostCSS processing with resources.PostProcess

resources.PostProcess delays processing of a resource until the rest of the build has finished.

This allows the public folder or Hugo's hugo_stats.json file to be used as the content for PurgeCSS, so that only CSS that is used on the final website will be included.

Close #2318
This commit is contained in:
George Cushen 2021-06-01 19:35:57 +01:00
commit 01a25ecaec

View file

@ -198,6 +198,10 @@
{{- if hugo.IsProduction -}}
{{- $style = $style | fingerprint "md5" -}}
{{- end -}}
{{- if eq (getenv "WC_POST_CSS") "true" -}}
{{/* PostProcess must be last action in the pipeline */}}
{{- $style = $style | resources.PostProcess -}}
{{- end -}}
<link rel="stylesheet" href="{{ $style.RelPermalink }}" />
{{ partial "marketing/google_analytics" . }}