Just to get this out of the way, if at all possible, I would like to do this without putting them in a directory with the application name inside the application’s static folder, it feels redundant. If this is the only way, then this is life.
I use:
STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', )
and
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
which compiles JS and SASS when running collectstatic. They are both located in the APP_ROOT / static / directory.
The only problem is that it combines all the sass and js source files with it. At some point, I am going to push it all towards S3, and I would like to avoid this if possible.
I found that if you run:
python manage.py collectstatic -i sass -i js
It still compiles JS and CSS files that I specified, leaving the rest of the source files. Unfortunately, it also ignores every js file in / admin / since it matches / admin / js / etc. I don’t even know if this might be a problem for this particular project, but I can foresee other applications in the future. I definitely want to enable static js / css stored in the application.
What I would like to do is something like:
python manage.py collectstatic -i app_name/sass -i app_name/js
And as I mentioned above, a simple solution is to simply prefix my static files in a folder named app_ /, like django.contrib.admin. However, at this point you get the directory structure PROJECT_ROOT / app_name / static / app_name / [js | sass | img | data] /, and I think it should be possible to avoid redundancy.
Again, maybe this is the best option to avoid conflict with other applications?
I have studied the possibility of writing custom repositories and search engines, and I think it is possible to do this on my own. I wanted to check here, although first, to make sure that this is a problem that someone else has solved, or to make sure that the overwhelming answer is simply to add a prefix directory.
If I were to roll on my own, the path that I think I would take would expand django.contrib.staticfiles.finders.AppDirectoriesFinder and override list() . I’m not sure yet that this approach will work, I need to track more how the actions of the collective management team are progressing, so if someone has done this or something like that before or knows why it will / will not work, any help will be appreciated.
Thanks!