gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
76.14k stars 7.54k forks source link

hugo mod vendor doesn't work for modules that only import other modules #10123

Open writeonlycode opened 2 years ago

writeonlycode commented 2 years ago

Sometimes it's useful to create modules that just packages a GitHub repository. For example: I was trying to create a Hugo Module that just packages Splide JS repository:

[module]
[module.hugoVersion]
extended = true
[[module.imports]]
path="github.com/splidejs/splide"
[[module.imports.mounts]]
source = "dist"
target = "assets/splide"

That works fine: the module doesn't have any files, it just imports some files from somewhere else. The problem: when I use this module, and try to vendorize it, Hugo complains that the module doesn't have any mounts. That's bad, because now I can't vendozire the repository that's getting imported through the module...

This isn't super bad, and can be solved somewhat easily: I just have to include some random file in the module and mount it. But it would be nice if we didn't need this hack to get the module vendorized...

I suspect that this either an intended behavior, or it's at least a go issue, but maybe it's possible to solve on Hugo's side... Not sure.

bep commented 2 years ago

Yea, we should try to to fix this. I guess this is the reason why I created this at some point in time:

https://github.com/bep/empty-hugo-module