Skip to content

Disable staticfiles.storage to generate URLs #86

@petrprikryl

Description

@petrprikryl

Staticfiles serving was implemented to leverage Django's new support_js_module_import_aggregation.

But I think it is not production ready yet. On my projects it is not working either.

Next, without support_js_module_import_aggregation it could be very dangerous to provide 2 versions of JS module.
Assume this scenario:

  1. django-vite provides entrypoint.<vitehash>.<djangohash>
  2. Entrypoint imports more modules
  3. One of these modules imports entrypoint (circular). But, the reference is without djangohash becasue files were not processed by Django. So the entrypoint is re-evaluated and our app crash.

I think static files should be used only with support_js_module_import_aggregation. So it make sense to introduce something like DJANGO_VITE_USE_STATICFILES to be able to control it. Or even better to check if STATICFILES_STORAGE has enabled support_js_module_import_aggregation?

Btw. compression works in whitenoise even if the file is served directly as original, entrypoint.<vitehash> in our case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions