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

<script src="https://unpkg.com/lunr/lunr.js" crossorigin="anonymous"></script>

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

{{- if eq hugo.Environment "development" }}
  {{- $baseJsResources := resources.Match "js/*.js" | resources.Concat "js/bundle.js" | js.Build | 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 }}