resources.Concat doesn't fail, but produces nothing

it’s simpler to see:

{{$searchjs := resources.Get “js/search.js”}}
{{$menuresetjs := resources.Get “js/menu-reset.js”}}
{{$flexsearchjs := resources.Get “js/flexsearch.min.js”}}
{{$clipboardjs := resources.Get “js/clipboard.js”}}
{{$swregisterjs := resources.Get “js/sw-register.js”}}
{{- $styles := resources.Get “main.scss” | resources.ExecuteAsTemplate “main.scss” . | resources.ToCSS (dict “transpiler” “dartsass”) | minify | fingerprint “md5” }}
{{- $bundlejs := slice $searchjs $menuresetjs $flexsearchjs $clipboardjs $swregisterjs | resources.Concat “js/bundle.js” | resources.ExecuteAsTemplate “js/bundle.js” . | minify | fingerprint “md5” }}

Error: error building site: EXECUTE-AS-TEMPLATE: failed to transform "js/bundle.js" (text/javascript): template: js/bundle.js:185:46: executing "js/bundle.js" at <resources.ExecuteAsTemplate>: error calling ExecuteAsTemplate: type <nil> not supported in Resource transformations

I don’t understand why concat doesn’t produce bundle.js, all my files are present in due location:

4096 /home/drm/WEBSITE/assets/js
  590 ├──􀀀  clipboard.js 
  18K ├──􀀀  flexsearch.min.js 
  206 ├──􀀀  menu-reset.js 
 2613 ├──􀀀  search.js 
  222 ├──􀀀  sw-register.js 
 1254 └──􀀀  sw.js 

I think concatenation is working fine. The error message is about resources.ExecuteAsTemplate.

Does one of your JS files contain a resources.ExecuteAsTemplate statement?

search.js

{{ $searchDataFile := printf “%s.search-data.json” .Language.Lang }}
{{ $searchData := resources.Get “search-data.json” | resources.ExecuteAsTemplate $searchDataFile . | resources.Minify | resources.Fingerprint }}

sw-register.js

{{- $swJS := resources.Get “sw.js” | resources.ExecuteAsTemplate “sw.js” . -}}

I honestly have no clue what I’m doing. I merely followed this guide

Then you probably shouldn’t be doing it.

Please contact the author of the guide.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.