Hugo Modules : mounting entire import

Hi, I’m using Hugo Modules to import several JS libraries from GitHub Repos.

Some have their distribution files in a /dist or /src folder, or something similar.

I’m able to do something like this :

module :
  imports :
    - # lazyload
      disable : false
      path : github.com/verlok/lazyload
      mounts :
          - source : dist
            target : assets/js/vendor

However, some repos have their distribution files at root. So, I would want to do something like this to just mount everything:

module :
  imports :
    - # other lib
      disable : false
      path : github.com/.../otherlib
      mounts :
          - source : 
            target : assets/js/vendor

but I’m getting Error: invalid module config for "github.com/.../otherlib": both source and target must be set

I’ve also tried to set source to the file name; no luck.

Am I missing something? or is this a current limitation.

You need a directory (or a filename) in the source value, not sure how that can be a limitation. Try “.”.

1 Like

:pray:
thank you seems to work!

any chance that modules could pull from GitHub Releases?
see: https://help.github.com/en/articles/linking-to-releases#linking-to-the-latest-release

I’ve tried to import the repo and mount releases/latest/download/ (as well as directly importing this dir) but the import isn’t happening getting a nil pointer error when trying to insert the resource.

(NB. the repo that I’m trying to pull from is: https://github.com/processing/p5.js if that gives a little context)

  • A GitHub release is a Git tag (with some infrastructure around it, like source archives)
  • Hugo Modules supports and encourages (semver) tagged versions.

But note that trying to mount “releases/latest/download/…” is not the way to go about it.

For sure.

So is there (currently) a way with Hugo Modules to tell import to import a release/latest release? I don’t know if you had a chance to look at the repo, but the release build is not “in” the repo (you can access it via “Releases”, though). Might be getting into NPM territory, but I think that this might be a good use case for Hugo Mods.

So, if the source is only in the release build, that is

If the release artifacts is only in the release build/page, that is true. But I have not seen any NPM builds where the distribution isn’t also commited and versioned in Git, e.g.: