luc2
luc2

Reputation: 567

Automatically remove source files after collectstatic with django-pipeline

With django-pipeline, is it possible to automatically remove source files after collectstatic ?

for example :

PIPELINE_JS = {
    'stats': {
        'source_filenames': (
          'js/jquery.js',
          'js/d3.js',
          'js/application.js',
        ),
        'output_filename': 'js/stats.js',
    }
}

collectstatic :

$ python manage.py collectstatic
$ ls static/js
jquery.js
d3.js
application.js
stats.js

(i don't want jquery.js, d3.js, application.js)

Upvotes: 1

Views: 551

Answers (1)

jazgot
jazgot

Reputation: 2073

Django-pipeline sends signals whenever it compiles package, you can read more about this in docs, and about signals in general here. You can hook this signal like this:

from pipeline.signals import js_compressed

def clear_files(sender, **kwargs):
    print kwargs
    if 'package' in kwargs:
        print kwargs['package'].sources
        # here remove unwanted files

js_compressed.connect(clear_files)

Upvotes: 1

Related Questions