Using Hugo Pipes introduced in 0.43
we can now inline critical-path css and minify it in production.
{{ $vendor := resources.Get "css/critical-vendor.css" }}
{{ $theme := resources.Get "css/critical-theme.css" }}
{{ $custom := resources.Get "css/critical-custom.css" }}
<style>
{{- if .Site.IsServer -}}
{{ (slice $vendor $theme $custom | resources.Concat "").Content | safeCSS }}
{{- else -}}
{{ (slice $vendor $theme $custom | resources.Concat "styles.css" | minify).Content | safeCSS }}
{{- end -}}
</style>
This could be improved by allowing Concat
to work in pipes like:
{{ (slice $vendor $theme $custom | concat | minify).Content | safeCSS }}