Last active
April 28, 2020 21:08
-
-
Save hwalinga/3cd4ade4478cfb80a6ee887fc5035cf5 to your computer and use it in GitHub Desktop.
Include replacing of ES6 imports for ManifestStaticiFilesStorage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.staticfiles import storage | |
class IncludeJavascriptImportsStaticFilesStorage(storage.ManifestStaticFilesStorage): | |
""" | |
Include patterns that deal with the javascript import files. | |
It is important to note that the pattern only matches if the file path | |
starts with / or ./ or ../ | |
I.e. it only matches if the file path is explicitly absolute or relative. | |
This is to reduce false positives in comments. (Which has happened.) | |
""" | |
patterns = storage.HashedFilesMixin.patterns + ( | |
("*.js", ( | |
(r"""( from ["'](\.{,2}/.*?\.js))""", """ from '%s'"""), | |
)),) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment