chore: proper dev and prod styles handling

This commit is contained in:
Xin 2023-08-28 22:32:07 +01:00
parent 283c7daaf2
commit c0d15f89e8

View File

@ -1,14 +1,25 @@
{{ if and (not hugo.IsProduction) (eq hugo.Environment "theme")}}
{{ $styles := resources.Get "css/styles.css" }}
{{ $styles = $styles | resources.PostCSS (dict "inlineImports" true) }}
{{- if and (not hugo.IsProduction) (eq hugo.Environment "theme") }}
{{- $styles := resources.Get "css/styles.css" }}
{{- $styles = $styles | resources.PostCSS (dict "inlineImports" true) }}
<link href="{{ $styles.RelPermalink }}" rel="stylesheet" />
{{ else }}
{{ $styles := resources.Get "css/compiled/main.css" }}
{{ $styles = $styles | minify | fingerprint | resources.PostProcess }}
{{- else }}
{{- $styles := resources.Get "css/compiled/main.css" -}}
{{- if hugo.IsProduction }}
{{- $styles = $styles | minify | fingerprint }}
<link rel="preload" href="{{ $styles.RelPermalink }}" as="style" />
<link href="{{ $styles.RelPermalink }}" rel="stylesheet" integrity="{{ $styles.Data.Integrity }}" />
{{ end }}
{{- else }}
<link href="{{ $styles.RelPermalink }}" rel="stylesheet" />
{{- end }}
{{- end }}
{{ $custom := resources.Get "css/custom.css" }}
{{ $custom = $custom | minify | fingerprint }}
<!-- Custom CSS -->
{{- $custom := resources.Get "css/custom.css" }}
{{- if hugo.IsProduction -}}
{{- $custom = $custom | minify | fingerprint }}
<link href="{{ $custom.RelPermalink }}" rel="stylesheet" integrity="{{ $custom.Data.Integrity }}" />
{{- else }}
<link href="{{ $custom.RelPermalink }}" rel="stylesheet" />
{{- end }}