Asset minification options (CSS)


#1

I’m handling my CSS as a Hugo Resource.

Minification (ex. hugo --minify or resources.Get "styles/main.scss" | resources.ToCSS | resources.Minify) with Hugo causes some of my CSS to be altered, reducing the support I had planned.

I always minify my site with hugo --minify, but that also alters any CSS embedded in the HTML.

For example, rgba(rr, gg, bb, aa) is translated to #rrggbbaa hex notation, which has less support.

Such conversion is not intended, so how can I configure Hugo’s minification behavior?


#2

It’s tempting to focus on your example here to dismiss your concern :slight_smile: Long time I didn’t see a caniuse chart soooo green.

To answer your question, no there is no way to pass your own settings to the minify feature, either the --minify cli flag or the resources.Minify method.


#3

#4

@regis that caniuse chart actually gives me 79.11% coverage for #rrggbbaa support – leaving out 1/5 users. Not great for a minor minification gain…

If I could only minify the html with Hugo, and not the CSS embedded in the HTML, that would be nice. I would handle the CSS with an external tool, like gulp.

Anyway, I got my answer – no control over minification behavior.


#5

I’m sorry I was a bit cocky here.

For this specific issue though, the team is rooting for you: https://github.com/tdewolff/minify/issues/238