JS Build with concat

How to make js.Build sourcemap to work. Now I get error no Resource provided in transformation

{{ $jscode := resources.Get "js/libs.min.js" -}}
{{ $jscode2 := resources.Get "js/app.js" -}}
{{ $jsb := slice $jscode $jscode2 | resources.Concat "js/default.js" -}}
<script src="{{ $jsb.RelPermalink }}" async="async" crossorigin="anonymous"></script>
{{ $js := resources.Get $jsb -}}
{{ $js := resources.Get $jsb | js.Build  (dict "sourcemap" "inline" ) }}

resources.Concat returns a resource not a global asset. Do not try to get it. ( see return value in docs)

code defensive using with or if to ensure you get what you expect.

so there is no solution?

right from the bat i would think of [quote=“Ajdegar, post:1, topic:56304”]
{{ $js := $jsb | js.Build (dict "sourcemap" "inline" ) }}
[/quote]

and then call the .Relpermalink after on $js

Start with the example from the docs and plug in your concat befor the jsbuild

did I mention the docs are not that bad before?

I have read the docs and need a solution.

You need to look into JavaScript imports. Make app.js import the lib and things will work better for you.

1 Like

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