Hugo needs either this or has to allow the use of relative paths like "../node_modules...." in concat pipelines. At the moment I have to copy all needed files into the assets folder before using it to concat - which doubles the files "laying around". node_modules has to be outside of the assets directory in root, otherwise, other build scripts won't work.
@davidsneighbour yes, we need to fix this -- but the problem with symbolic links is that they create its own set of problems/challenges on change detection. I'm not sure that is such a problem inside /assets -- but I suspect a better solution to this would be to allow multiple asset dirs, e.g.
assetDir = ["assets", "node_modules"]
And probably also alias the plural version:
assetDirs = ["assets", "node_modules"]
Not sure how the path resolution would work here, but ideally I would want to do resource.Get "my_node_module/css/foo.css".
the problem with symbolic links is that they create its own set of problems/challenges on change detection. I'm not sure that is such a problem inside /assets -- but I suspect a better solution to this would be to allow multiple asset dirs
Prior to Hugo 0.50 a symlink under /assets/ that pointed to /static/images/ was working fine, no problems whatsoever.
Since then I have to use disableBrowserError in the config for the project to build but still I get a console ERROR in the form of ...failed to render "/"...
I'm not sure if multiple assetDirs would be the solution to this problem but it does seem like an improvement from the current situation, (that is kind of annoying since 0.50).
@onedrawingperday not sure what the "it worked before" post before brings to this discussion.
@bep You asked above and I replied:
I'm not sure that is such a problem inside /assets
Anyway Happy Holiday!
I'm currently trying to do a neat way of handling JS and bundling directly in our Hugo based projects, and just now i ran into needing this feature.
My current example is that i have an array of the scripts in my config.toml and then i range over that array to use resources.Concat.
[params.js]
partials = [
'../node_modules/jquery/dist/jquery.min.js',
'../node_modules/jquery-validation/dist/jquery.validate.min.js',
'scripts/generic/global.js',
'scripts/generic/parallax.js',
'scripts/generic/format.js',
'scripts/generic/intro.js',
'scripts/navigation/smooth-scroll.js',
'scripts/navigation/sticky-nav.js',
'scripts/gallery/modal.js',
'scripts/contact/google-maps.js',
'scripts/contact/validation.js',
'scripts/contact/send-mail.js'
]
{{ $js := slice }}
{{ range .Site.Params.js.partials }}
{{ $js = $js | append (resources.Get . ) }}
{{ end }}
{{ $scripts := $js | resources.Concat "dist/scripts.js" | resources.Minify }}
<script type="text/javascript" src="{{ $scripts.Permalink }}"></script>
The error the above code gives: <resources.Get>: error calling Get: FindFirstFile F:\Hugo\project-name\assets\node_modules\jquery\dist\jquery.min.js: The syste m cannot find the path specified.
Right now, to make it easier for my self, i will just include those two node includes directly into the assets folder. But having the option to move outside the assets folder would be awesome!
Most helpful comment
Hugo needs either this or has to allow the use of relative paths like "../node_modules...." in concat pipelines. At the moment I have to copy all needed files into the assets folder before using it to concat - which doubles the files "laying around". node_modules has to be outside of the assets directory in root, otherwise, other build scripts won't work.