I've configured pipeline as follows:

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',

)

# Static files storage
STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'

# Pipeline JS compressor
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.jsmin.JSMinCompressor'

PIPELINE_JS = {
    'website-main': {
        'source_filenames': (
          'shared/jquery/jquery-1.10.2.min.js',
          'shared/bootstrap/js/bootstrap.min.js',
          'shared/jquery/jquery.cookie.js',
        ),
        'output_filename': 'pipeline-compressed/website-main.js',
    }
}

When I use {% compressed_js 'website-main' %} in my template I get a script tag for each of the 3 files configured in PIPELINE_JS. Shouldn't I see a single script tag with src="pipeline-compressed/website-main.js".

有帮助吗?

解决方案

Set settings.DEBUG to False to use compressed files. Or set settings.PIPELINE_ENABLED to True.

According to Usage - django-pipeline, the setting checked is simply PIPELINE, but upon viewing the source of version 1.3.15, you'll find that the setting is in fact PIPELINE_ENABLED:

The templatetags will either output the source filenames or the compressed filenames, depending on the PIPELINE setting, if you do not specify the PIPELINE setting, the source files will be used in DEBUG-mode, and compressed files in non-DEBUG-mode.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top