build_js template

This commit is contained in:
Eryn Wells 2024-08-03 09:27:04 -07:00
parent 24a0b6aa5e
commit 13e564d388

View file

@ -0,0 +1,19 @@
{{- $resourcePath := .resource -}}
{{- $minify := .minify | default true }}
{{- $resource := dict -}}
{{- 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 }}
{{ warnf "Unable to find JavaScript resource: %s" $resourcePath }}
{{- end }}
{{ return $resource }}