Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Commit a0c4016

Browse files
authored
Fingerprint style file in production only (#92)
Signed-off-by: Patrice Chalin <pchalin@gmail.com>
1 parent ffae4ac commit a0c4016

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

layouts/partials/css.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
{{ $inServerMode := site.IsServer -}}
1+
{{ $inProd := hugo.IsProduction -}}
22
{{ $includePaths := (slice "node_modules") -}}
33
{{ $sass := "sass/custom.sass" -}}
44
{{ $cssOutput := "css/style.css" -}}
55
{{ $devOpts := (dict "targetPath" $cssOutput "includePaths" $includePaths "enableSourceMap" true) -}}
66
{{ $prodOpts := (dict "targetPath" $cssOutput "includePaths" $includePaths "outputStyle" "compressed") -}}
7-
{{ $cssOpts := cond $inServerMode $devOpts $prodOpts -}}
7+
{{ $cssOpts := cond $inProd $prodOpts $devOpts -}}
88
{{ $css := resources.Get $sass | resources.ExecuteAsTemplate "blah.sass" . | toCSS $cssOpts -}}
9-
{{ if $inServerMode -}}
10-
<link rel="stylesheet" href="{{ $css.RelPermalink }}">
11-
{{ else -}}
9+
{{ if $inProd -}}
1210
{{ $prodCss := $css | fingerprint -}}
1311
<link rel="stylesheet" href="{{ $prodCss.RelPermalink }}" integrity="{{ $prodCss.Data.Integrity }}">
12+
{{ else -}}
13+
<link rel="stylesheet" href="{{ $css.RelPermalink }}">
1414
{{ end -}}

0 commit comments

Comments
 (0)