hugo
hugo copied to clipboard
Hugo Pipes: Add post-render transformation support
@regisphilibert posted this link https://github.com/client9/csstool the forum. It strips unused CSS rules from a CSS.
I had a look at it and thought initially that it would be hard to add to the current Hugo Pipes, as the current transformers (PostCSS, SCSS etc.) does not have the information needed (e.g. public/**/*.html
) for something like "CSS filtering" to work.
But we can, of course, add a concept of "delayed transformations" to Hugo pipes, so one could do something like:
{{ $css := resources.Get "scss/main.scss" | toSCSS | minify | css.Cut "**/*.html" | fingerprint }}
With the above, we delay the execution until the rendered content is available.
Note that the new namings in the above is just dropped in there without too much thought. The above would typically be a "production only" thing, as I suspect it would take more than some milliseconds to run.