1

I am getting started with django-pipeline. If I understand it correctly, I need to specify the directories with my CSS/JS files to compress them. However, this is a tedious task as my project is quite big and has static files here and there (not only under /static/ directory).

I saw that it has collectstatic integration but it is not what I thought: it just runs the compressor after collecting the static files, and will only compress the files you manually specified in the settings and not all the static files.

Is there any way I could tell django-pipeline to just compress every static file I have?

Bob Dem
  • 991
  • 1
  • 11
  • 23

1 Answers1

1

You can use glob syntax to select multiples files. Like this way,

You don't want to use collectstatic right ?

then use this way,

from django.contrib.staticfiles import finders

all_js = ["{0}/{1}".format(st,"*.js") for st in finders.find("", all=True)]
all_css = ["{0}/{1}".format(st,"*.css") for st in finders.find("", all=True)]

PIPELINE_CSS = {
    'colors': {
        'source_filenames': tuple(all_css),
        'output_filename': 'css/colors.css',
        'extra_context': {
            'media': 'screen,projection',
        },
    },
}

PIPELINE_JS = {
    'stats': {
        'source_filenames': tuple(all_js),
        'output_filename': 'js/stats.js',
    }
}
dhana
  • 6,487
  • 4
  • 40
  • 63
  • I am aware of the glob syntax, however I cannot include all the CSS files in a single one as it would be a mess (i.e. overwriting properties from section to section). It is more like, collect the files and compress them, I have no need to group them, they are grouped already. – Bob Dem Jun 19 '14 at 06:38