Opened 4 years ago
Closed 4 years ago
#32383 closed New feature (fixed)
ManifestStaticFilesStorage doesn't update JavaScript source map references
Description (last modified by ) ¶
ManifestStaticFilesStorage replaces URL's in CSS files with the hashed equivalents, but doesn't have any other out-of-the-box rules. One common use case for cross-static-file-references is a JavaScript source map, a structured comment in a JS file.
I think it would be a reasonable inclusion that Django modifies these too. I got it working (with Whitenoise's subclass of ManifestStaticFilesStorage
) with this extra regex pattern:
from whitenoise.storage import CompressedManifestStaticFilesStorage class SuperStaticFilesStorage(CompressedManifestStaticFilesStorage): patterns = CompressedManifestStaticFilesStorage.patterns + ( ( "*.js", ( ( r"(//# sourceMappingURL=(.*?\.js\.map))$", "//# sourceMappingURL=%s", ), ), ), )
Ideally the regex would start with a ^
, which requires the regex mulitline flag, and would NOT be compiled in case-insenstive mode. The current storage implementation forces compiling regexes with only the case insensitive flag.
Change History (7)
comment:1 by , 4 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 4 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
comment:3 by , 4 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 4 years ago
Description: | modified (diff) |
---|---|
Owner: | set to |
Status: | new → assigned |
comment:6 by , 4 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Yep. If we can do this then super 👍