Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken references in static files #4

Open
joshuanunn-aqc opened this issue Jan 16, 2024 · 0 comments
Open

Broken references in static files #4

joshuanunn-aqc opened this issue Jan 16, 2024 · 0 comments

Comments

@joshuanunn-aqc
Copy link

I've stumbled upon a similar issue to that reported in dpd-static-support/issues/3, except in this case I'm not using Whitenoise and it occurs when using the built-it Django collectstatic command using ManifestStaticFilesStorage.

When collecting static files with Django>=4.2.0 (and the the Django project makes use of dpd-static-support), Django raises an exception and aborts the collection:

$ python manage.py collectstatic
...
Post-processing 'dash/component/dpd_static_support/static/dpd_static_support/css/bootstrap-grid.min.css' failed!
...
Traceback (most recent call last):
...
ValueError: The file 'dash/component/dpd_static_support/static/dpd_static_support/css/bootstrap-grid.min.css.map' could not be found with <django.contrib.staticfiles.storage.ManifestStaticFilesStorage object at 0x7fdc0a1d5bb0>.

The reason this fails is because the Django collectstatic command picks up on the comments inside the js and css files which describe the corresponding map files. In this case bootstrap-grid.min.css contains a comment referencing a non-existent map file: /*# sourceMappingURL=bootstrap-grid.min.css.map */.

Arguably, this is really a bug in Django itself https://code.djangoproject.com/ticket/21080, but I don't think it's going to get resolved anytime soon given the age of the ticket. It might be worth some small changes in this repo, which I think would also resolve similar issues seen with Whitenoise.

Potential solutions might include:

  • the map file comments could be stripped from each of the js and css files, but then of course these do not match the downloaded versions/hashes.
  • perhaps a better alternative is to also include the map files themselves in the distribution?

For anyone else getting the same issue, you can tell Django not to run post-processing when using collectstatic to skirt around the issue: python manage.py collectstatic --no-post-process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant