feat: Don't minify when debug params is true

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
This commit is contained in:
Simon 2021-10-21 22:23:34 +02:00
parent 1221094d75
commit 2e74dbfa2b
2 changed files with 14 additions and 3 deletions

View File

@ -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 }}
<script src="{{ $secureJS.Permalink }}" integrity="{{ $secureJS.Data.Integrity }}"></script>
{{ end }}

View File

@ -1,2 +1,9 @@
{{ $style := resources.Get "styles/main.sass" | toCSS | minify | fingerprint }}
<link rel="stylesheet" href="{{ $style.Permalink }}">
{{ $style := resources.Get "styles/main.sass" }}
{{ with $style }}
{{ $styleCSS := . | toCSS }}
{{ if not $.Site.Params.debug }}
{{ $styleCSS = $styleCSS | minify }}
{{ end }}
{{ $styleCSS = $styleCSS | fingerprint }}
<link rel="stylesheet" href="{{ $styleCSS.Permalink }}" integrity="{{ $styleCSS.Data.Integrity }}">
{{ end }}