Skip to content

Commit

Permalink
fix: CSS fingerprinting when using Hugo's -e arg (#2017)
Browse files Browse the repository at this point in the history
Hugo allows two ways to set a production environment.

The HUGO_ENV approach used by Netlify was working fine, but in case of running `hugo server -e production`, the CSS file wasn't fingerprinted.
  • Loading branch information
paazca authored Dec 5, 2020
1 parent a67ec5e commit 9675a85
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions wowchemy/layouts/partials/site_head.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@
{{ $css_comment := printf "/*!* Wowchemy v%s (https://wowchemy.com/) */\n" site.Data.wowchemy.version }}
{{ $css_bundle_head := $css_comment | resources.FromString "css/bundle-head.css" }}
{{ $css_options := dict "targetPath" "css/wowchemy.css" }}
{{- if (in (slice (getenv "HUGO_ENV") hugo.Environment) "production") -}}
{{- if eq hugo.Environment "production" -}}
{{- $css_options = merge $css_options (dict "outputStyle" "compressed") -}}
{{- end -}}
{{ $sass_template := resources.Get "scss/main.scss" }}
{{ $style := $sass_template | resources.ExecuteAsTemplate "main_parsed.scss" . | toCSS $css_options }}
{{ $style := slice $css_bundle_head $style | resources.Concat "css/wowchemy.css" }}
{{- if (eq (getenv "HUGO_ENV") "production") -}}
{{- if eq hugo.Environment "production" -}}
{{- $style = $style | minify | fingerprint "md5" -}}
{{- end -}}
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
Expand Down

0 comments on commit 9675a85

Please sign in to comment.