jaysonsantos / jinja-assets-compressor

A Jinja extension (compatible with Flask and other frameworks) to compile and/or compress your assets.
Other
93 stars 10 forks source link

Keep reference to original file name in compressed file name #77

Open victorkristof opened 4 years ago

victorkristof commented 4 years ago

Hi there,

Thanks for the great library!

I was wondering whether we could add an option to keep a reference to the original file name in the compressed file name?

For example, if I have a custom.css and wrap it around a {% compress 'css' %} block, the new file name will be something like 5ef7a08e1b4dfe00216375aa6b9ecc0d.css.

I would love to have it transformed into something like custom.5ef7a08e1b4dfe00216375aa6b9ecc0d.css, so that I know that this file is a compression of custom.css.

Thanks!

jaysonsantos commented 4 years ago

Hey there, thanks for your report. I guess it would be possible by having a second argument on compress like {% compress 'css' 'name-of-the-final-file' %} because inside the block there can be many link, css and, script blocks and it would hard to guess a name there. What do you think?

victorkristof commented 4 years ago

Hi Jayson,

I didn't think of the case of compressing multiple files in one, but you're right! And that's a good idea.

So writing {% compress 'css' 'my-stylesheets' %} would generate a file called my-stylesheets.{hash}.css. And it would work for compressing one or more files in one.I like it :)