#33353: Can't collect static files if don't have vendor's JavaScript source map
files
-------------------------------------+-------------------------------------
Reporter: Michael | Owner: nobody
Type: Bug | Status: new
Component: contrib.staticfiles | Version: 4.0
Severity: Release blocker | Resolution:
Keywords: manifeststatic | Triage Stage:
storage | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Michael):
For anyone else stuck on this problems, this is how you can get around it:
{{{
from django.contrib.staticfiles.storage import ManifestStaticFilesStorage
from core.jslib.manifest import module_patterns
module_patterns = (
('*.js', (
(
r"""(^|;)\s*(?P<matched>(?P<prefix>import(\s*\*\s*as\s+\w+\s+|\s+\w+\s+|\s*{[\w,\s]*?}\s*)from\s*)['"](?P<url>.*?)['"])""",
"%(prefix)s '%(url)s'",
),
)),
)
def get_static_url(path):
from django.contrib.staticfiles.storage import staticfiles_storage
return staticfiles_storage.url(path)
class LcManifestStaticFilesStorage(ManifestStaticFilesStorage):
"""
ManifestStaticFilesStorage with additional features:
1. If you have a manifest files error, the page to render the error
probably
has the same error, and then you can't debug it. This returns the
error
string so one can see in the rendered html there was a problem
2. Remove the sourcemap patterns, add javascript module support.
"""
# ------ Temp until:
https://code.djangoproject.com/ticket/33353#comment:11
no_sourcemap_patterns = (
("*.css", (
r"""(?P<matched>url\(['"]{0,1}\s*(?P<url>.*?)["']{0,1}\))""",
(
r"""(?P<matched>@import\s*["']\s*(?P<url>.*?)["'])""",
"""@import url("%(url)s")""",
),
)),
)
patterns = no_sourcemap_patterns + module_patterns
# ------
# patterns = ManifestStaticFilesStorage.patterns + module_patterns
def stored_name(self, name):
try:
return super().stored_name(name)
except ValueError as e:
return
f"{name}.could_not_find_static_file_to_calc_manifest_hash, {e}"
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33353#comment:12>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.bd1c508fa7320a4881617a9a2ddc00f1%40djangoproject.com.