Skip to main content

Pipeline is an asset packaging library for Django.

Project description

Jazzband GitHub Actions Coverage Documentation Status

Pipeline is an asset packaging library for Django, providing both CSS and JavaScript concatenation and compression, built-in JavaScript template support, and optional data-URI image and font embedding.

Django Pipeline Overview

Installation

To install it, simply:

pip install django-pipeline

Quickstart

Pipeline compiles and compress your assets files from STATICFILES_DIRS to your STATIC_ROOT when you run Django’s collectstatic command.

These simple steps add Pipeline to your project to compile multiple .js and .css file into one and compress them.

Add Pipeline to your installed apps:

# settings.py
INSTALLED_APPS = [
    ...
    'pipeline',
]

Use Pipeline specified classes for STATICFILES_FINDERS and STATICFILES_STORAGE:

STATICFILES_STORAGE = 'pipeline.storage.PipelineManifestStorage'

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

Configure Pipeline:

# The folowing config merges CSS files(main.css, normalize.css)
# and JavaScript files(app.js, script.js) and compress them using
# `yuglify` into `css/styles.css` and `js/main.js`
# NOTE: Pipeline only works when DEBUG is False
PIPELINE = {
    'STYLESHEETS': {
        'css_files': {
            'source_filenames': (
                'css/main.css',
                'css/normalize.css',
            ),
            'output_filename': 'css/styles.css',
            'extra_context': {
                'media': 'screen,projection',
            },
        },
    },
    'JAVASCRIPT': {
        'js_files': {
            'source_filenames': (
                'js/app.js',
                'js/script.js',
            ),
            'output_filename': 'js/main.js',
        }
    }
}

Then, you have to install compilers and compressors binary manually.

For example, you can install them using NPM and address them from node_modules directory in your project path:

PIPELINE.update({
    'YUGLIFY_BINARY': path.join(BASE_DIR, 'node_modules/.bin/yuglify'),
})
# For a list of all supported compilers and compressors see documentation

Load static files in your template:

{% load pipeline %}
{% stylesheet 'css_files' %}
{% javascript 'js_files' %}

Documentation

For documentation, usage, and examples, see: https://django-pipeline.readthedocs.io

Issues

You can report bugs and discuss features on the issues page.

Changelog

See HISTORY.rst.

Project details


Release history Release notifications | RSS feed

This version

4.0.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_pipeline-4.0.0.tar.gz (71.8 kB view details)

Uploaded Source

Built Distribution

django_pipeline-4.0.0-py3-none-any.whl (75.4 kB view details)

Uploaded Python 3

File details

Details for the file django_pipeline-4.0.0.tar.gz.

File metadata

  • Download URL: django_pipeline-4.0.0.tar.gz
  • Upload date:
  • Size: 71.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for django_pipeline-4.0.0.tar.gz
Algorithm Hash digest
SHA256 0ab1190d9dc64e2f7b72be3f7b023c06aca7cc1cc61e7dc9f0343838e29bbc88
MD5 221e44d34b402898b6e7b858b786e0ef
BLAKE2b-256 49f512c83c33f0d6cd93a7b1498a1b3ae9bd86828f1f739998f59c5249d7504e

See more details on using hashes here.

File details

Details for the file django_pipeline-4.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_pipeline-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90e50c15387a6e051ee1a6ce2aaca333823ccfb23695028790f74412bde7d7db
MD5 04805cda24139fcb13068dfe52b8fdb2
BLAKE2b-256 2d057258f4b27839d186dfc29f9416475d236c2a64f25ff64a22e77d700eb753

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page