Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "hugo npm" wrapper command (assets dependencies) #5567

Open
bep opened this issue Dec 26, 2018 · 6 comments
Open

Add "hugo npm" wrapper command (assets dependencies) #5567

bep opened this issue Dec 26, 2018 · 6 comments
Labels
Milestone

Comments

@bep
Copy link
Member

bep commented Dec 26, 2018

This is related to #5374. But there are many problems/drawbacks with using symbolic links to extend Hugo's directory structure.

This is me thinking out loud, but I think we need to do better. On a general level (for content, static etc.) but I think we can start with /assets.

For SCSS and dependencies inside node_modules you would probably use SCSS relative imports, and that works great. But if you want to, say, concatenate other resources (JS, CSS), you end up with, let's say, less pretty solutions :-)

If we could figure out a way to pull in dependencies as configuration (0.53's config dir comes in handy here) from node_modules without dumping it all in (we have feature request about a ´resources.GetMatch` function with glob support, so we don't want to dump everything in there ...)

So, this is two-folded (at least):

  1. I want to compose my /assets folder from several, and possibly also set custom "root names", e.g. static/images => assets/staticimages
  2. I want an easy way to pull in dependencies defined in package.json

The first part isn't hard -- the hard part is to agree on a good configuration format.

The second part is harder to get right, I think. I have been thinking about creating a simple wrapper around npm and possibly also some kind of machine-writable text format inside config/_default/npm_asstets.txt or something.

So I could do:

hugo npm install vue

Or ...

hugo npm install --all

Or something.

And that we, by default, mapped the dist directory, so if you did hugo npm install vue you could do:

{{ resources.Get "vue/vue.js" }}

This is me thinking out loud. To be continued.

And note that I'm not talking about copying files from node_modules; these will still be links, but at the application level.

/cc @regisphilibert @budparr and gang

@bep bep added the Proposal label Dec 26, 2018
@bep bep added this to the v0.54 milestone Dec 26, 2018
@earthboundkid
Copy link
Contributor

Maybe {{ resources.FromNode "vue/vue.js" }} tells Hugo to look in the different node_modules directories for an asset. I like having a different name than .Get because using the same name makes the inheritance process unclear. You might have something in node_modules change and things break but you don't know why, etc. Using FromNode at least points users in the direction of why something broke.

@bep bep modified the milestones: v0.54, v0.55, v0.56 Jan 26, 2019
@stale
Copy link

stale bot commented Jun 1, 2019

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.

@stale stale bot added the Stale label Jun 1, 2019
@vincent99
Copy link
Contributor

I would still appreciate and use a clean way to pull in node_modules files as resources so that I do not have to maintain a copy of 3rd party libraries in my website's source tree.

What we actually currently do at my company is put symlinks to ../../node_modules/(whatever) intoassets/js. This does work but is awkward. We only ever run Hugo in a docker container so a developer/doc writer never actually has a node_modules dir on their filesystem and the links are all "broken".

@stale stale bot removed the Stale label Jun 1, 2019
@earthboundkid
Copy link
Contributor

I suppose you could also set assets = [“assets”, “node_modules”] in your config file

@bep bep modified the milestones: v0.56, v0.57 Jun 14, 2019
@bep bep modified the milestones: v0.57, v0.58 Jul 31, 2019
@bep bep modified the milestones: v0.58, v0.59 Aug 13, 2019
@bep bep modified the milestones: v0.59, v0.60 Sep 6, 2019
@bep bep modified the milestones: v0.60, v0.61 Oct 21, 2019
@bep bep modified the milestones: v0.61, v0.62, v0.63 Nov 25, 2019
@bep bep modified the milestones: v0.63, v0.64 Dec 11, 2019
@bep bep modified the milestones: v0.116.0, v0.117.0 Aug 1, 2023
@bep bep modified the milestones: v0.117.0, v0.118.0 Aug 30, 2023
@bep bep modified the milestones: v0.118.0, v0.119.0 Sep 15, 2023
@bep bep modified the milestones: v0.119.0, v0.120.0 Oct 4, 2023
@bep bep modified the milestones: v0.120.0, v0.121.0 Oct 31, 2023
@bep bep modified the milestones: v0.121.0, v0.122.0 Dec 6, 2023
@bep bep modified the milestones: v0.122.0, v0.123.0, v0.124.0 Jan 27, 2024
@bep bep modified the milestones: v0.124.0, v0.125.0 Mar 4, 2024
@bep bep modified the milestones: v0.125.0, v0.126.0 Apr 23, 2024
@bep bep modified the milestones: v0.126.0, v0.127.0 May 15, 2024
@bep bep modified the milestones: v0.127.0, v0.128.0 Jun 8, 2024
@bep bep modified the milestones: v0.128.0, v0.129.0 Jun 21, 2024
@bep bep modified the milestones: v0.129.0, v0.131.0 Jul 22, 2024
@bep bep modified the milestones: v0.131.0, v0.133.0 Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants