hugo icon indicating copy to clipboard operation
hugo copied to clipboard

Named mounts not working with Hugo’s generated `jsconfig.json`

Open UtkarshVerma opened this issue 4 years ago • 7 comments
trafficstars

I have a module for Twitter Bootstrap v5 which mounts js to assets/bootstrap. The mounts are configured here: https://github.com/UtkarshVerma/hugo-modules/blob/main/bootstrap-v5/config.yaml

With this configured, I just have to import my Bootstrap plugins like import ScrollSpy from 'bootstrap/src/scrollspy' and my JS gets built successfully. But I noticed a minor caveat, VS Code fails to resolve my import paths, and I think I know why.

Here is my jsconfig.json:

{
 "compilerOptions": {
  "baseUrl": ".",
  "paths": {
   "*": [
    "*",
    "../../../../../tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/twbs/[email protected]+incompatible/js/*"
   ]
  }
 }
}

The issue is that it is telling VS Code to resolve all import paths relative to js rather than bootstrap/js for the Bootstrap module. A fix for this would be for Hugo to add mount point's target path (relative to assets) and add a key-value pair accordingly in "paths" in jsconfig.json. For example, for this case, jsconfig.json should be like:

{
 "compilerOptions": {
  "baseUrl": ".",
  "paths": {
   "*": ["*"],
   "bootstrap/*": ["../../../../../tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/twbs/[email protected]+incompatible/js/*"]
  }
 }
}

I can confirm that this works.

UtkarshVerma avatar Jun 17 '21 10:06 UtkarshVerma

What do you mean by "named mounts"? How are they different from the mounts that are working?

bep avatar Jun 17 '21 11:06 bep

I meant to imply that the module is not mounted directly to assets, but in its subdirectory.

UtkarshVerma avatar Jun 17 '21 11:06 UtkarshVerma

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 0.001 ETH (2.4 USD @ $2399.96/ETH) attached to it as part of the @15100899254 fund.

gitcoinbot avatar Jun 17 '21 15:06 gitcoinbot

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 265 years, 5 months from now. Please review their action plans below:

1) 15100899254 has started work.

Go it twice,so easy,and fixed it!

Learn more on the Gitcoin Issue Details page.

gitcoinbot avatar Jun 17 '21 15:06 gitcoinbot

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 0.001 ETH has been submitted by:


gitcoinbot avatar Jun 17 '21 15:06 gitcoinbot

@bep Could we please block gitcoinbot as spam? They won't probably realise until 265 years from now.

davidsneighbour avatar Jun 17 '21 15:06 davidsneighbour

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open. If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

github-actions[bot] avatar Jun 18 '22 02:06 github-actions[bot]

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.

github-actions[bot] avatar Sep 05 '22 02:09 github-actions[bot]