How to use require.js for managing JavaScript dependencies in a Django project?
-
14-07-2021 - |
Domanda
I use RequireJS for managing dependencies between my JavaScript libraries and modules. The backend is written in Django. Django has many apps for managing static assets, but none of them talk about incorporating the r.js compiler.
What's the best way to manage and compile my JS files using r.js in Django?
My requirements are:
- Versioned output file to get around caching when the file is updated.
- Automatically use uncompiled JS file when
DEBUG = True
insettings.py
for Django, and the compiled file whenDebug = False
. - Some of the libraries will be loaded from CDN (such jquery) with a local fallback.
Any suggestions will be much appreciated.
Soluzione
Seems as though django-require covers at least some of what you need, https://github.com/etianen/django-require .
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow