Hugo update from 0.100.2 to 0.104.3 breaks js minification

Hey Team Hugo. First time poster here. Been using Hugo for a while now and I’ve build some wonderful sites thanks to Hugo <3

I was hitting a bit of a snag with the latest hugo update. I have a fairly simple js file with with mainly some boilerplate alpinejs setup and an unused lottie player import. When hugo minifies the the js it gives me a nasty error:

hugo serve
Start building sites …
hugo v0.104.3+extended darwin/amd64 BuildDate=unknown
Error: Error building site: MINIFY: failed to transform "js/build.js" (application/javascript): identifier ProjectInterface has already been declared on line 7470 and column 10
 7470:       }, ProjectInterface = function() {
                ^
Built in 420 ms

Now it’s a simple fix remove the unused import but thought it would be useful to mention that tdewolff/minify is breaking inside of hugo between versions.

I hear you.

As to JavaScript minification of external files, I highly recommend that you instead do it via js.Build:

{{ $js := resources.Get "js/build.js" | js.Build (dict "minify" hugo.IsProduction)
1 Like

Thanks I’ll try that