I have a module for Twitter Bootstrap v5 which mounts js to assets/bootstrap.
The mounts are configured here:
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/bootstrap@v5.0.1+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/bootstrap@v5.0.1+incompatible/js/*"]
]
}
}
}
I can confirm that this works.
But you need to open an issue on GitHub.