Skip to content

Error with staticfiles collection and missing source map files #4045

@pamelafox

Description

@pamelafox

What happened?

When I ran collectstatic on my production server, I get this error:

Traceback (most recent call last):
  File "/tmp/8daedd4f753e458/manage.py", line 31, in <module>
    execute_from_command_line(sys.argv)
  File "/tmp/8daedd4f753e458/antenv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/tmp/8daedd4f753e458/antenv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/tmp/8daedd4f753e458/antenv/lib/python3.10/site-packages/django/core/management/base.py", line 414, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/tmp/8daedd4f753e458/antenv/lib/python3.10/site-packages/django/core/management/base.py", line 460, in execute
    output = self.handle(*args, **options)
  File "/tmp/8daedd4f753e458/antenv/lib/python3.10/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 209, in handle
    collected = self.collect()
  File "/tmp/8daedd4f753e458/antenv/lib/python3.10/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 154, in collect
    raise processed
whitenoise.storage.MissingFileError: The file 'js/popper.js.map' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7851a54578b0>.

The JS file 'js/vendors.js' references a file which could not be found:

  js/popper.js.map

Please check the URL references in this JS file, particularly any
relative paths which might be pointing to the wrong location.

The error comes because popper.js has this comment:

//# sourceMappingURL=popper.min.js.map

But popper.min.js.map is not copied into the static files directory.

This general issue is reported as an issue in Django 4.1:
https://code.djangoproject.com/ticket/33353#comment:15
And there was a fix to django-rest-framework to add source map files:
encode/django-rest-framework#8591

I am not sure why I am seeing this in Django 4.0.8, since it's supposedly a 4.1 issue, but perhaps 4.0.8 manifests an earlier version of the issue.

Proposed fix

This is the change I made to my repo:
pamelafox/cookiecutter-django-output@c5e8166

I modified the gulpfile to copy over the *.map files for the vendor files, and add *.map to the gitignore file.

I can submit that as a pull request to this repository if it seems like a helpful change.

Additional details

This is the repository I deployed:
https://github.com/pamelafox/cookiecutter-django-output/tree/961a1ebfd226ec1aa0726760e4c2fd46b7bc0840

I deployed using the 'azd up' command to Azure App Service (using infrastructure files I wrote myself), and I found the error in the deployment center logs.

I do not seem to get the error when I run manage.py collectstatic locally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions