Skip to content

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

Open
@bep

Description

@bep

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions