Concat error when bundling js files from theme

I’m attempting to bundle some JS assets, following the example from the docs here: https://gohugo.io/hugo-pipes/bundling/

I’m getting the following error: error calling Concat: slice []interface {} not supported in concat. Here’s the relevant code in my partial.

{{ $jquery := resources.Get "js/lib/jquery.min.js" }}
{{ $anime := resources.Get "js/lib/anime.min.js" }}
{{ if eq .Site.Params.includeBootstrapJs true }} }}
  {{ $bootstrap := resources.Get "js/lib/bootstrap.bundle.min.js" }}
  {{ $js := slice $jquery $bootstrap $anime | resources.Concat "js/bundle.js" }}
{{ else }}
  {{ $js := slice $jquery $anime | resources.Concat "js/bundle.js" }}
{{ end }}
<script src="{{ "js/bundle.js" | relURL }}"></script>

The assets in question are located in /themes/hugo-base-theme/static/js/lib/.

I’ve had a look at this issue and not able to understand how the solution there would apply to my use case.

Relevant changes are in this diff.

I’m able to get it working, but only by moving the JS files from the theme to ./assets. Is there any way around that? We have several hugo projects and we like to simply move the relevant theme files when starting a new project.

It looks like the site setting assetDir will work when pointed to a dir in the theme, despite some commentary in the git repo that (maybe) suggests otherwise…

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