gohugoio / hugo

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

`hugo mod npm pack` ignores `module.replacements` configuration #8711

Closed schnerring closed 3 years ago

schnerring commented 3 years ago

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.84.2-E0C67958+extended windows/amd64 BuildDate=2021-06-28T10:59:21Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes.


I currently build a theme from scratch that includes an exampleSite that I use to develop the theme. I use npm to bundle prismjs which works fine. I also got hugo mod npm pack working to generate the package.config for my exampleSite/:

[module]
  replacements = "github.com/schnerring/hugo-gruvbox -> ../.."
  [[module.imports]]
    path = "github.com/schnerring/hugo-gruvbox"

I haven't investigated whether or not this behavior is intended but when specifiying the theme with theme = ["github.com/schnerring/hugo-gruvbox"] instead of using [[module.imports]], the replacements functionality doesn't work.

The actual bug is that hugo mod npm pack doesn't care about the replacements part and skips to upstream. This also happens when explicitly using replace inside the .mod file. This means that one has to push changes upstream first to be able to generate the files with hugo mod npm pack.

This took me a while to figure it out since replacements with a local module worked, but hugo mod npm pack didn't.

schnerring commented 3 years ago

I'm not sure what the issue was but I got it working.

The only issue remaining is the part where replacements only works with [[module.imports]] but not with setting via theme = [ ... ].

bep commented 3 years ago

but not with setting via theme = [ ... ].

How can you set it there?

schnerring commented 3 years ago

You said both were equivalent (correct me if I'm wrong):

This:

[module]
  [[module.imports]]
    path = "github.com/yihui/hugo-xmin"
  [[module.imports]]
    path = "github.com/yourname/my-shortcodes"

Is the same as:

theme = ["github.com/yihui/hugo-xmin",  "github.com/yourname/my-shortcodes" ]
bep commented 3 years ago

You said both were equivalent (correct me if I'm wrong):

So, your two examples above is equivalent, but there is no way to add further configuration to the latter example. My memory may be faded here, but you need to pick one or the other.

schnerring commented 3 years ago

So replacements doesn't work for the latter example? If that's as it's intended to work, we can go ahead and close the issue.

bep commented 3 years ago

So replacements doesn't work for the latter example?

There is no way to add replacements to the latter example, but I suspect I understand where we're talking around each other.

The theme syntax was kept mostly for backwards compability reasons, and I'm pretty sure we don't do any clever merging of the two -- so it's either/or.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.