From 2e74dbfa2b98d9668621bbdc3534ef73c3544754 Mon Sep 17 00:00:00 2001 From: Simon C Date: Thu, 21 Oct 2021 22:23:34 +0200 Subject: [PATCH] feat: Don't minify when debug params is true MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pour se mettre en mode debug il faut modifier le fichier config.yml: params: debug: true On est obligé de passer par params puisque Hugo ne peut pas utiliser la variable debug directement --- layouts/partials/js.html | 6 +++++- layouts/partials/style.html | 11 +++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/layouts/partials/js.html b/layouts/partials/js.html index fcd88ef..926550a 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -1,5 +1,9 @@ {{ $js := resources.Get "js/main.js" }} {{ with $js }} -{{ $secureJS := . | js.Build | resources.Minify | resources.Fingerprint }} +{{ $secureJS := . | js.Build }} +{{ if not $.Site.Params.debug }} + {{ $secureJS = $secureJS | minify }} +{{ end }} +{{ $secureJS = $secureJS | fingerprint }} {{ end }} diff --git a/layouts/partials/style.html b/layouts/partials/style.html index e4dbc70..08a1639 100644 --- a/layouts/partials/style.html +++ b/layouts/partials/style.html @@ -1,2 +1,9 @@ - {{ $style := resources.Get "styles/main.sass" | toCSS | minify | fingerprint }} - +{{ $style := resources.Get "styles/main.sass" }} +{{ with $style }} +{{ $styleCSS := . | toCSS }} +{{ if not $.Site.Params.debug }} + {{ $styleCSS = $styleCSS | minify }} +{{ end }} +{{ $styleCSS = $styleCSS | fingerprint }} + +{{ end }}