Get django-piping and gazebo to play beautifully together

I install bower components in external/bower_components/ under my root project. I have additional static files under static , as well as some that are part of the installed applications. I am trying to use the django pipeline to minimize the static files that live in bower_components , while I leave only the static files.

My problem is that I cannot figure out how to use the django pipeline to minimize my bower components and at the same time not copy all the bower packages 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 get everything I want in staticfiles (material that was in the static base, as well as mini versions of things that were pulled from the gazebo), PLUS the full source of each package that is in gazebo. This works from an end-user perspective, but there is a lot of excess garbage that I really don't want there.

To get around this, I tried python manage.py collectstatic -i bower_components . But in this case, ignoring not only leads to the fact that collectstatic does not copy files, but also leads to the fact that the django pipeline does not see the files, but ends

If I try to use some custom pipeline crawlers, such as pipeline.finders.FileSystemFinder , it causes collectstatic ignore all the static scripts and css that I want from django.contrib.admin and my static/ folder.

Is there a way to get my cake and eat it so that I can get the collectstatic copy function to pay attention to one group, while the combination / minimization of the django pipeline draws attention to another group?

After that, I understand that the answer may be to explicitly collect and minimize all the scripts and css in my installed applications using PIPELINE_CSS and PIPELINE_JS , but this seems imperfect, because every time it will be an unusual overhead a new application is integrated.

+5
source share
1 answer

yes there is, but you need to change your static crawler to change the static crawler to use the django-piper finder:

 STATICFILES_FINDERS = ( 'pipeline.finders.FileSystemFinder', 'pipeline.finders.AppDirectoriesFinder', 'pipeline.finders.CachedFileFinder', 'pipeline.finders.PipelineFinder' ) 

Only the corresponding file should be copied here.

+2
source

Source: https://habr.com/ru/post/1214363/


All Articles