jazzband / django-tinymce

TinyMCE integration for Django
http://django-tinymce.readthedocs.org/
MIT License
1.28k stars 317 forks source link

Missing .map files causing collectstatic to fail using current master branch (TinyMCE 6) #460

Closed philgyford closed 6 months ago

philgyford commented 6 months ago

I tried out the current, unreleased, version of master f04e1c8 that includes TinyMCE v6, thanks to #426:

pipenv install -e git+https://github.com/jazzband/django-tinymce.git@master#egg=django-tinymce

It seemed to work fine with an initial test locally, but when I tried running manage.py collectstatic I got this error:

Post-processing 'tinymce/skins/ui/oxide-dark/content.inline.js' failed!

Traceback (most recent call last):
  File "manage.py", line 24, in <module>
    main()
  File "manage.py", line 20, in main
    execute_from_command_line(sys.argv)
  File "/root/.local/share/virtualenvs/code-_Py8Si6I/lib/python3.8/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/root/.local/share/virtualenvs/code-_Py8Si6I/lib/python3.8/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/root/.local/share/virtualenvs/code-_Py8Si6I/lib/python3.8/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/root/.local/share/virtualenvs/code-_Py8Si6I/lib/python3.8/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/root/.local/share/virtualenvs/code-_Py8Si6I/lib/python3.8/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 209, in handle
    collected = self.collect()
  File "/root/.local/share/virtualenvs/code-_Py8Si6I/lib/python3.8/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 154, in collect
    raise processed
whitenoise.storage.MissingFileError: The file 'tinymce/skins/ui/oxide-dark/content.inline.js.map' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0xffffa14393a0>.

The JS file 'tinymce/skins/ui/oxide-dark/content.inline.js' references a file which could not be found:
  tinymce/skins/ui/oxide-dark/content.inline.js.map

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

As you can see I'm using whitenoise, and I haven't tried it without.

I can't see any .map files in those tinymce/skins/ folders, but also can't see any in the version of TinyMCE 6 downloaded direct from the tiny.cloud website.

There are some closed issues for previous versions of TinyMCE in which they concluded that the released files shouldn't include references to .map files, e.g. https://github.com/tinymce/tinymce/issues/5489 and https://github.com/tinymce/tinymce/issues/4649 but can't see anything more recent. Still, maybe this is actually an issue for TinyMCE?

claudep commented 6 months ago

Thanks a lot for testing! Do you think we should remove the sourceMappingURL lines from the various TinyMCE source files?

philgyford commented 6 months ago

It seems like that's the approach they took before. I could open an issue there asking if they should be doing that, seeing as that was the previous approach?

claudep commented 6 months ago

Sure, you can always try!

philgyford commented 6 months ago

Here we go: https://github.com/tinymce/tinymce/issues/9484

In creating that I've realised it's unrelated to Whitenoise. The error also occurs using django.contrib.staticfiles.storage.ManifestStaticFilesStorage as Django's staticfiles backend.

If that's changed to django.contrib.staticfiles.storage.StaticFilesStorage then there's no error.

marius-mather commented 6 months ago

It looks like the official word from the Django project is that this should raise an error, and you should include the .map files if possible, see https://code.djangoproject.com/ticket/33353.

Other projects have fixed this issue by just removing the sourceMappingURL lines, e.g. https://github.com/farridav/django-jazzmin/issues/488. I will put up a PR to remove them here as well.