django-rest-framework
django-rest-framework copied to clipboard
Remove source map references
As reported here: https://code.djangoproject.com/ticket/33353#comment:15
The new CSS source map support in Django 4.1 blocks collectstatic
with ManifestStaticFilesStorage
with DRF, since it includes CSS files that have source map references but not the source maps themselves.
Steps to reproduce:
$ pip install django==4.1 djangorestframework==3.13.1
Collecting django==4.1
Using cached Django-4.1-py3-none-any.whl (8.1 MB)
Collecting djangorestframework==3.13.1
Using cached djangorestframework-3.13.1-py3-none-any.whl (958 kB)
Collecting asgiref<4,>=3.5.2
Using cached asgiref-3.5.2-py3-none-any.whl (22 kB)
Collecting sqlparse>=0.2.2
Using cached sqlparse-0.4.2-py3-none-any.whl (42 kB)
Collecting pytz
Using cached pytz-2022.1-py2.py3-none-any.whl (503 kB)
Installing collected packages: pytz, sqlparse, asgiref, django, djangorestframework
Successfully installed asgiref-3.5.2 django-4.1 djangorestframework-3.13.1 pytz-2022.1 sqlparse-0.4.2
$ django-admin startproject mysite
$ cd mysite
$ echo "STATIC_ROOT = 'static_root'" >> mysite/settings.py
$ echo "STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'" >> mysite/settings.py
$ echo "INSTALLED_APPS.append('rest_framework')" >> mysite/settings.py
$ python manage.py collectstatic --no-input
Post-processing 'rest_framework/css/bootstrap-theme.min.css' failed!
Traceback (most recent call last):
File "/home/don/Documents/django_test/mysite/manage.py", line 22, in <module>
main()
File "/home/don/Documents/django_test/mysite/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/don/Documents/django_test/venv_test/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/home/don/Documents/django_test/venv_test/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/don/Documents/django_test/venv_test/lib/python3.9/site-packages/django/core/management/base.py", line 402, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/don/Documents/django_test/venv_test/lib/python3.9/site-packages/django/core/management/base.py", line 448, in execute
output = self.handle(*args, **options)
File "/home/don/Documents/django_test/venv_test/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 209, in handle
collected = self.collect()
File "/home/don/Documents/django_test/venv_test/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 154, in collect
raise processed
File "/home/don/Documents/django_test/venv_test/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 338, in _post_process
content = pattern.sub(converter, content)
File "/home/don/Documents/django_test/venv_test/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 215, in converter
hashed_url = self._url(
File "/home/don/Documents/django_test/venv_test/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 152, in _url
hashed_name = hashed_name_func(*args)
File "/home/don/Documents/django_test/venv_test/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 388, in _stored_name
cache_name = self.clean_name(self.hashed_name(name))
File "/home/don/Documents/django_test/venv_test/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 113, in hashed_name
raise ValueError(
ValueError: The file 'rest_framework/css/bootstrap-theme.min.css.map' could not be found with <django.contrib.staticfiles.storage.ManifestStaticFilesStorage object at 0x7fdf21937b50>.
$
I tried removing the sourceMappingURL
lines from bootstrap-theme.min.css
and bootstrap.min.css
, and that fixed the problem.
Great, if you find time, could you make a PR to remove those lines, or to add the source map files to the repo?
I decided to remove the lines, instead of adding the source map files.
I decided to remove the lines, instead of adding the source map files.
Hrm. Removing parts of a minified CSS seems too easily broken in future changes. What change would we need to make if we wanted to instead add the source map files?
I just downloaded bootstrap 3.4.1 and it comes with the source map files:

It would just be a case of adding them in the repo. It seems in the past they've been deleted / not copied in.
I put up an alternate PR, #8591.