HashedFileMixin's pattern variable looks like it could be extended for other file types:
class HashedFilesMixin(object):
default_template = """url("%s")"""
patterns = (
("*.css", (
r"""(url\(['"]{0,1}\s*(.*?)["']{0,1}\))""",
(r"""(@import\s*["']\s*(.*?)["'])""", """@import url("%s")"""),
)),
)
But - if I read the code right - it can't. Because in post_process, the patterns are applied to all files matched by any of the extensions.
What I like to be able to achieve is get cache busting in some of my js files as well. I marked all static file references in my code with a 'staticFile()' call and then tried to customize django's CachedStaticFilesStorage like this:
class MyCachedStaticFilesStorage(django.contrib.staticfiles.storage.CachedStaticFilesStorage):
patterns = django.contrib.staticfiles.storage.HashedFilesMixin.patterns + (
(u'*.js', [
(r"""(staticFile\(['"]{0,1}\s*(.*?)["']{0,1}\))""", r"""staticFile("%s")""", )
]),
)
As of today, that won't work, since all CSS rules are applied to my JS, too, which causes some stuff to be replaced that shouldn't.
Is this a bug, and should I file a bug report? Is it worth fixing? How else can I get cache busting into JS files?
Thanks,
Bernhard