Merge pull request #67 from forty/forty/minify-css-in-prod

Minify CSS file for production builds
This commit is contained in:
Dmitry Kolosov 2020-10-26 18:07:02 +03:00 committed by GitHub
commit 460a61701f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,7 +15,11 @@
<link rel="apple-touch-icon-precomposed" href="{{ "favicon.png" | absURL }}"> <link rel="apple-touch-icon-precomposed" href="{{ "favicon.png" | absURL }}">
{{ $cssTemplate := resources.Get "css/main.css" }} {{ $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" }}
<link rel="stylesheet" href="{{ $style.Permalink }}" integrity="{{ $style.Data.Integrity }}"> <link rel="stylesheet" href="{{ $style.Permalink }}" integrity="{{ $style.Data.Integrity }}">
{{ range .Site.Params.customCSS -}} {{ range .Site.Params.customCSS -}}