nickjj / flask-static-digest

Flask extension to help make your static files production ready by md5 tagging and gzipping them.
MIT License
157 stars 27 forks source link

Update references in .css and .js files to other files so they refer to the cache-busting filenames #26

Open foarsitter opened 3 years ago

foarsitter commented 3 years ago

When an image is referenced from a css file it references to the unhashed version of the file. This could lead to issues when the referenced file is updated.

Django has this behavior implemented so we can use there patterns for replacing references in .css and .js files.

If this feature is wanted I will provide a pull request.

nickjj commented 3 years ago

Hi,

I would like to support the idea of referencing the hashed files in CSS / JS files. Does the Django approach end up doing a find / replace in the final bundled CSS / JS files afterwards instead of depending on a dynamic lookup like the Jinja template approach is doing with a custom helper?

foarsitter commented 3 years ago

My approach would be a find and replace since its a straightforward solution. Also, I'm not aware of the other approach you refer to.

nickjj commented 3 years ago

The other approach is how this extension works for Jinja templates. A new template function exists that's aware of the cache manifest file and does the lookup for the human readable file name to the hashed file name.