js.html

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

Source Code

{{- $opts := dict "minify" true }}

{{- if eq hugo.Environment "development" }}
  {{- $baseJsResources := resources.Match "js/*.js" | resources.Concat "js/bundle.js" | js.Build $opts | fingerprint -}}
  <script src="{{ $baseJsResources.RelPermalink }}" integrity="{{ $baseJsResources.Data.Integrity }}" crossorigin="anonymous"></script>
{{- else }}
  {{- $baseJsResources := resources.Match "js/*.js" | resources.Concat "js/bundle.js" | js.Build $opts | fingerprint  -}}
  <script src="{{ $baseJsResources.RelPermalink }}" integrity="{{ $baseJsResources.Data.Integrity }}" crossorigin="anonymous"></script>
{{- end }}