Bundling resources not working

Okay, got it. It’s because you were originally assigning js to a slice. This should now work. Note that I’ve removed the solution above as well. This now also settles your issue with getting different filenames:

<!-- MODIFIED FOR RESOURCES ISSUE DEMONSTRATION -->

{{ $.Scratch.Set "js" "" }}

{{ $.Scratch.Add "js" (( resources.Get "/src/js/components/jquery.min.js" ).Content) }}

{{ with .Params.include.footer.js }}
  {{ range . }}
    {{ $.Scratch.Add "js" ((resources.Get . ).Content) }}
  {{ end }}
{{ end }}

{{ $.Scratch.Add "js" ( (resources.Get "/src/js/some-code-that-must-go-after-everything.js" ).Content )}}

{{ $js := $.Scratch.Get "js" }}
<!--Give your js files names based on the page they are used in-->
{{ $scriptPath := printf "js/%s.js" ( .Name | urlize ) }}
{{ $scriptFromString := $js | resources.FromString $scriptPath | minify | fingerprint }}
<script src="{{$scriptFromString.RelPermalink}}"></script>
1 Like