- commit
- c1bba4c8d62b2d17ed73ec7520d19abaa073f17b
- parent
- 1c53cbae43b666274f9af06df05c4014d460d65c
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2025-02-07 17:00
add npm finder
Diffstat
| A | utils/npm_finder.py | 24 | ++++++++++++++++++++++++ |
1 files changed, 24 insertions, 0 deletions
diff --git a/utils/npm_finder.py b/utils/npm_finder.py
@@ -0,0 +1,24 @@ -1 1 from django.conf import settings -1 2 from django.contrib.staticfiles.finders import BaseFinder -1 3 from django.core.files.storage import FileSystemStorage -1 4 -1 5 -1 6 class NpmFinder(BaseFinder): -1 7 """ -1 8 If we would just add node_modules to STATICFILES_DIRS, -1 9 collectstatic would copy a lot of files that we don't -1 10 actually need. -1 11 -1 12 See also https://github.com/deeprave/django-npm-finder -1 13 """ -1 14 -1 15 def __init__(self, apps=None, *args, **kwargs): -1 16 self.storage = FileSystemStorage(location=settings.NPM_PATH) -1 17 -1 18 def find(self, path, all=False): -1 19 full_path = self.storage.path(path) -1 20 return [full_path] if all else full_path -1 21 -1 22 def list(self, ignore_patterns): -1 23 return [(str(p), self.storage) for p in settings.NPM_FILES] -1 24