hugo-resource-builders/layouts/partials/resource_builders/build_js.html

21 lines
535 B
HTML
Raw Normal View History

2024-08-03 09:27:04 -07:00
{{- $resourcePath := .resource -}}
{{- $minify := .minify | default true -}}
2024-08-03 09:27:04 -07:00
{{- $resource := dict -}}
2024-08-03 09:27:04 -07:00
{{- with resources.Get $resourcePath }}
{{- if eq hugo.Environment "development" }}
{{- with . | js.Build }}
{{ $resource = . }}
{{- end }}
{{- else }}
{{- $opts := dict "minify" $minify }}
{{- with . | js.Build $opts | fingerprint }}
{{ $resource = . }}
{{- end }}
{{- end }}
{{- else }}
2024-08-03 09:27:04 -07:00
{{ warnf "Unable to find JavaScript resource: %s" $resourcePath }}
{{- end }}
{{ return $resource }}