-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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 vendor
and resources.Vendor
#13309
Comments
As far as I can tell from experimentation, the existing
It sounds like the Questions:
|
@jmooring OK, so now I have slept a little on this. I haven't edited my text above, but I think it holds mostly water, but I think we'll:
A note to self: I think we need to be a little lenient with the key used to vendor these resources, e.g. from the example above: {{ $opts := dict
"inlineImports" true
"optimize" (not hugo.IsDevelopment)
}} If I run
I want the vendored EDIT IN: OK, looking at the |
There's a very rough implementation of this in #13310
|
I'm closing this for now. I will come up with something very similar, but I will outline that more precisely in a different issue. |
Note
This proposal is a bit half-baked. I've certainly thought about it a lot over the years, and a concrete implementation popped into my head while sleeping last night, so I thought I'd get it down on paper while it's fresh.
I have spent an excessive amount of time trying to avoid npm as much as possible in Hugo's
assets
building. However, in some cases, it's hard to avoid. TailwindCSS just released their v4 version, and it's a great piece of software that works well with Hugo.Unfortunately, this requires
npm
to be practical.1We have a new theme for gohugo.io built with TailwindCSS v4 on its way. Unfortunately, currently, you need to do this the first time you're running the site:
This is not ideal if you just want to fix some typos, and it's not great when we include the Hugo documentation in the source distribution (inside
/docs
in the main repo). I'm betting that people can build thev0.141.0
version of the documentation fairly easily in 20 years. With annpm
build step in the mix, all bets are off.I have thought about ways to fix this, including testing out my own npm Go Module proxy. Below is my latest take on how to solve this in a general way, which should also work for e.g., Dart Sass.
Using TailwindCSS as an example, this is how I imagine it would look in the templates:
resources.Vendor
may take options in the future, but for now, I see it as a simple marker that tells Hugo to vendor/use the vendored version of the previous transformation using a shallow key of that transformation's:Resource
'sPath
andContent
This is more or less how we do it today for the file cache inside
/resources
.We already have a
hugo mod vendor
command that writes to_vendor
. I suggest that we move those down to_vendor/mod
so we can add another_vendor/resources
root folder for these.If we then consolidate
hugo mod vendor
into a new top-level command, we could make it look like:Running
hugo vendor -resources
will:_vendor/resources
.resources.Vendor
).When running
hugo
orhugo server
, we will by default use vendored assets/modules. To enable development, we need to rethink the current--ignoreVendorPaths
flag and module config a little.The above should obviously also work for themes/Hugo Modules. In fact, given how our current vendoring works, it will be great to finally be able to use themes/modules with complex build setups without having anything but
hugo
installed.Footnotes
It is possible to download the TailwindCSS CLI binary and put it in the
PATH
for a npm-less setup (and it may also be worth looking into WebAssembly when we go further down that route), but you quickly find the need fornpm
once you want to include the great Typography plugin. I guess it's also possible to use thebuild.useResourceCacheWhen=always
, but that's only practical in very simple setups. ↩The text was updated successfully, but these errors were encountered: