From 8f5c578e1d3e1b40fb23b60c3b34b3f2fed0edfc Mon Sep 17 00:00:00 2001 From: Quentin Barbe Date: Sun, 25 Oct 2020 23:20:32 +0100 Subject: [PATCH] Minify CSS file for production builds --- layouts/partials/head.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 48b6ebd..bc8bcf0 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -15,7 +15,11 @@ {{ $cssTemplate := resources.Get "css/main.css" }} -{{ $style := $cssTemplate | resources.ExecuteAsTemplate "css/style.css" . | resources.ToCSS | resources.Fingerprint "sha256" }} +{{ $style := $cssTemplate | resources.ExecuteAsTemplate "css/style.css" . | resources.ToCSS }} +{{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }} + {{ $style = $style | resources.Minify }} +{{ end }} +{{ $style = $style | resources.Fingerprint "sha256" }} {{ range .Site.Params.customCSS -}}