css.html

This partial layout concatenates all modular CSS files found in themes/milo/assets/css and outputs a bundle.css file for deployment use. It also minifies and fingerprints the output.

Source code


{{- $cssResources := slice (resources.Get "css/main.css") }}
{{- $cssResources = $cssResources | append (resources.Get "css/fonts.css") }}
{{- $cssResources = $cssResources | append (resources.Get "css/syntax.css") }}

{{- if eq hugo.Environment "opensource" -}}
{{- $cssResources = $cssResources | append (resources.Get "css/colors-opensource.css") }}
{{- else -}}
{{- $cssResources = $cssResources | append (resources.Get "css/colors.css") }}
{{- end -}}

{{- if eq hugo.Environment "development" }}
  {{- $cssBundle := $cssResources | resources.Concat "css/bundle.css" }}
  <link rel="stylesheet" href="{{ $cssBundle.RelPermalink }}">
{{- else }}
  {{- $opts := dict "minify" true }}
  {{- $cssBundle := $cssResources | resources.Concat "css/bundle.css" | minify | fingerprint }}
  <link rel="stylesheet" href="{{ $cssBundle.RelPermalink }}" integrity="{{ $cssBundle.Data.Integrity }}" crossorigin="anonymous">
{{- end }}