-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
The big assets handling / resource transformation funcs naming thread #4854
Comments
This looks mighty cool but how about using a shorter namespace than Like For example
I also think that Just my 2 cents. |
For my own understanding so that I might provide some useful input, is the idea something like:
Regardless, I think there is an advantage to continuing to call it resources if it addresses more than just the |
How about |
Sure. I didn't go for the plural because that will be used for the /assets/ folder. Don't know if there might be a conflict. Anyway it's for @bep to decide (I just made a suggestion).
Not as confusing as
From what I understand it will not be as simple as that. Page Bundle Resources are already Hugo assets ready for processing. |
So, a I think we should stick to plural to match the other namespaces ( Which reads better than |
I feel like fingerprint and digest should just be available on the object by default? Needing to explicitly add |
I really like: It reads great and it’s self explanatory. |
Holy Tintinnabulation Batman :) This is great stuff. |
Not sure what you mean by the object. But we have methods for image resize operations etc. They are very specific to images. But adding all of the above "transformers" as funcs and not methods makes it a little more explicit that this is a chain -- a stream of processes. And it makes it more clear that you create a new instance based on some original. Also, making it a "cross resource concern" avoids having to walk around an implement it for every Given this example:
Looking at the above it is obvious that you don't want to publish the intermediate steps, you are only interested in the final product. Under the hood this can (and is) implemented very effective in a streaming fashion knowing this. |
@RealOrangeOne note that I have now added |
@bep sorry, by 'object', i mean the Resource, the thing that comes out the end of the stream. Obviously I know it's got its own ticket, but IMO So, what i'm suggesting is more like: (Note the missing
(Mid way through writing this, i realised |
I think that |
I agree. Of those 2, I think |
[[EDIT]] Removing previous comments once realizing that @regisphilibert's recommendations below make the most sense 😄 |
So in a Page Bundle context, current Hugo developers know that We are used to using Beside
|
@regisphilibert yes, I like using But you are right about the usefulness of |
Too bad for GetMatch but I don't think it would have been used this often, To get back on |
So, the main use case for this (in my head, anyway) is to concatenate resources of the same media type (not sure what would be the end result if you mix and match, but I will have to come to that). So you would control the order by the argument order to {{ $bundle := resources.Concat | slice (resources.Get "first.css") (resources.Get "second.css") }}
{{ $minified := $bundle | resources.Minify }} Or I guess this should also work: {{ $bundle := resources.Concat (resources.Get "first.css") (resources.Get "second.css") }}
{{ $minified := $bundle | resources.Minify }} The bundle variant of the above would be: {{ $bundle := resources.Concat | resources.Match "*.css" }}
{{ $minified := $bundle | resources.Minify }} Note that the above is just me jotting on paper. It would be cool with a |
This would not give control over the order of the files though, which is rather important in most of the case. (I forgot in which order |
Yes it would. The files will be sorted before they are "picked". So you can number your files or whatever. |
That said, I have no ambition to solve all the problems in one go. The important part of this particular issue is the names. |
I seem to have been confusing |
Can we discuss the name of the feature in here as well? How are we going to refer to it in the doc, in the discourse, in the community? This is about asset management, but a lot of people will instantly understand the impact this will have on their workflow if we identify it also as a task runner (like grunt and gulp). We don't want it to call it what it's not, and it's not a task runner, but something which rings like it maybe... |
Yes, that would be great. But I'm not sure "task runner" is appropriate. I'm starting to get something that is actually working here, and I like this more and more. And what I like most about it (right after the speed) is the simple model of just chaining this into my templates where I use the asset (CSS etc.). I have similar (in concept) with Gulp running as a separate process ... With CSS => static, and then some very elaborate minification fingerprinting process with the renaming of files and string replacement in some template ... And some clever logic to do fingerprinting in production, but not in development ...
The above is clarity to me. And that template variable assignment is valid in Go 1.11! There will always people saying that "yes, well, you really need the Asdf NPM JS plugin to umfify your scripts ..." I have said it before and I say it again: I'm ready to sacrifice a lot of flexibility to get the clarity above. And if you look at |
So Pipeline, Pipes, which gives a sense of running tasks (gulp uses the plumbing semantic a lot) coud be dropped in there... :)
Can't stop grinning looking at the above! 😁 |
Pipeline, tasks ... Reads to me a something "running a set of tasks/jobs/script", "running as a batch", i.e. something that is declared in a build config and is ... not fast. But I don't have a good suggestion for an alternative. |
I am missing something about |
|
Thanks.
Now, I'm having a hard trim grasping the concept of |
I was going to say "wait for the documentation", but since you're the one who be writing that (:-)):
{{ $r := "Hugo Rocks!" | resources.FromString "rocks/hugo.txt" }} You will typically pipe in the content from some source ... But reading the above, I think we can improve and make the |
I am closer to getting it, I'm curious to find out the content of |
I have reverted my thoughts on the template part of this. I added
|
I see just like |
Going back to the
Optimizing for terseness and clarity for the simplest use cases. The permalink might be something like |
@clipperhouse the only sensible default would be |
Hey @regisphilibert @kaushalmodi @lucperkins @onedrawingperday and gang: I have updated the table in my first post in this thread to match the current -- and possibly final -- name scheme. All the functions marked with a green check is implemented. The others can wait. Any final complains or suggestions? (and please don't make it a "could you also add ...") See #4854 (comment) I have some support work to do in this area (build scripts etc.) that needs to be done, but other than that the implementation is more or less solid. |
Looks awesome! |
So everything is ready but two functions :) Awesome! Can't wait to try it out!
|
I'm not sure who you include in the "we" above, but I suspect this will be very individual. To me, the biggest part of this is the SCSS -- and if you combine that with |
I guess I mean the early adopters. More to the point, I meant we can live without |
Curious as to whether you have decided to implement the aliases you mentioned above as well for this particular set of transformers, @bep. |
I have. |
This is about naming so I'll write about this here instead of #4858. The postCSS method seems to deal only with autoprefixer, but postCSS unless I am wrong is a tool to build your css using plugins lots of... in a Gulp or Grunt environment. So it seems to do much more than autoprefixing. Unless I misunderstood the purpose of |
Hi, this is an awesome feature to have. A native asset pipeline processor is great ! I hope some docs are included to get a better picture on how to invoke it on a whole site and such. Also, I don't see references to image optimization, although I don't seem to find a go implementation of this kind of feature either. In any case, great job ! |
It will work with Hugo's current Image Processing |
That's limiting as |
Damn. This is is huge! I did misunderstand |
Looks awesome @bep I’ve been away on a holiday but I’ll be back just in time for the release. |
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. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This is related to #4429 and #4381 but put in its own thread to get the attention it deserves.
Resource
object given a path to a file in /assets (configurable). This also works for images that you can then scale. Anything with a MIME type recognized by Hugo (and you can define your own if you want).resources.Get
, but uses pattern matching to find the first match.Resource
objects matching the given pattern. Seeresources.Concat
for a function that could use this.Resource
to CSS based on the source MIME type. In the first version, we will supportSCSS
. An implementation note here is that we will persist the result of this transformation, so if you later run this from a non-SASS-enabled Hugo, it will still work. When we finally get some proper plugin support in Hugo, these resource transformations will be candidates to queue up and send to external processors.Resource
based on the source MIME type. Currently supportscss
,js
,json
,html
,svg
,xml
. It will get a newRelPermalink
andPermalink
, e.g./css/main.min.css
.Resource
; it will get a newRelPermalink
andPermalink
, e.g./css/main.eae6b4ebececc2bbd7490966a5e01bcc.css
. It defaults tosha256
, but you can pass eithermd5
,sha256
orsha512
as an argument..Data.Integrity
on fingerprinted resources. See https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity. Note that if you want theIntegrity
, but don't care about the fingerprinting (aka cache-busting part), you can just apply the fingerprint function, and just use.Data.Integrity
(i.e. not useRelPermalink
etc.)Resource
objects. Think of this as a poor man's bundler.Resource
and data context (e.g..Site
) as a Go template. Use your imagination for use cases for this one :-)Resource
from a string.All of the above can be chained. So you can do
{{ (resources.Resource "styles.scss" | resources.ToCSS | resource.Minify | resources.FingerPrint).RelPermalink }}
etc.Note that I'm not sure that all of the above will arrive in the next Hugo version, but most of these are cheap to implement once the "resource chain" infrastructure is in place.
So I want your input on the above. And note that most of these requires a
Resource
object to work. You may like or hate that term, but it's there. Which is a reason I have put all of these funcs into theresources
namespace.The text was updated successfully, but these errors were encountered: