I am installing bower components to external/bower_components/
under my project root. I have additional static files under static
as well as some that are part of installed apps. I'm trying to use django-pipeline to minify static files that all live in bower_components
while I leave other static files alone.
My problem is that I can't figure out how to use django-pipeline to minify my bower components while at the same time not copying all the bower packages over to the destination directory.
in settings.py
:
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
os.path.join(os.path.dirname(__file__), '..', 'external'),
)
STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'
PIPELINE = True
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'pipeline.finders.PipelineFinder',
)
When I run python manage.py collectstatic
, I end up with everything I want over in staticfiles
(stuff that was in the static base as well as the minified versions of things that were pulled in from bower), PLUS the full source of every single package that's in bower. This works from the perspective of the end user, but there's a lot of excess junk that I don't actually want in there.
To work around this, I tried python manage.py collectstatic -i bower_components
. But in this case, the ignore not only causes collectstatic
to not copy the files over, but it also causes django-pipeline to not see the files, and it ends up
If I try to use some the custom pipeline finders like pipeline.finders.FileSystemFinder
it causes collectstatic
ignore all static scripts and css that I want from django.contrib.admin
and my static/
folder.
Is there a way I can have my cake and eat it too such that I can get collectstatic
's copy function to pay attention to one group while django-pipeline's combination/minification pays attention to a different group?
After writing this out I realize that the answer might be to explicitly collect and minify all scripts and css in my installed apps with PIPELINE_CSS
and PIPELINE_JS
but that seems non-ideal since it would be unusual overhead every time that a new app is integrated.
yes there is, but you need to modify your static finder to change your static finder to use django-pipeline finders:
STATICFILES_FINDERS = (
'pipeline.finders.FileSystemFinder',
'pipeline.finders.AppDirectoriesFinder',
'pipeline.finders.CachedFileFinder',
'pipeline.finders.PipelineFinder'
)
This should copy only relevant file there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With