我开始使用django-pipeline了。如果我理解正确的话,我需要用我的CSS/JS文件指定目录来压缩它们。然而,这是一个单调乏味的任务,因为我的项目相当大,并且到处都有静态文件(不仅在/ static /目录下)。
我看到它有集合静态集成,但并不是我想的那样:它只是在收集静态文件后运行压缩器,并且只会压缩您在设置中手动指定的文件,而不会压缩所有静态文件。
有没有办法让django-pipeline只压缩我拥有的每个静态文件?
发布于 2014-06-19 14:36:06
您可以使用glob语法选择多个文件。就像这样,
你不想使用集合体,对吧?
那就用这种方式,
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',
}
}https://stackoverflow.com/questions/24300121
复制相似问题