Minify JS not working with concatenated resources

Hi all,

Let’s say I have a js file a.js with the following content:

(function (){
  let asdfasdf = "asdf";

If I use this resource pipe:

{{ $dscript := (resources.Get "js/dsav/dsav.js") | resources.Minify  | resources.Fingerprint }}

and use the link, I see the following minified output in both live server and static file:

(function(){let a = "asdf";console.log(a)})()

But if I use the same file in a slice and use resources.Concat, in live server I see proper minified output. But in static generated file, I see the below:

(function (){let asdfasdf = "asdf";console.log(asdfasdf);})()

The issue is that the file is minified properly if processed separately. But when concatenated with other files and minified, the output in static generated file is not minified properly.

Any suggestions?

Thank you,

Minification with concatenated JS resources works fine. I know because I use it in my projects.

So I suggest that you share a repo that replicates the issue you experienced for people in this forum to have a look.

Also which Hugo versions are you using locally and in production?

1 Like

There is a minification option (here in yaml):

      keepVarNames: true

I’m using version 0.88 in production.
Tried using the latest version v0.91.2 and the issue is not reproduced.

Strangely when I reverted back to the older 0.88 version and built the site, the issue not reproduced now.

I’ll get back if I’m able to reproduce it in a new repo.

Thank you

1 Like

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