Git Product home page Git Product logo

luyidong / django-pipeline Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jazzband/django-pipeline

0.0 0.0 0.0 1.28 MB

Pipeline is an asset packaging library for Django.

Home Page: https://django-pipeline.readthedocs.io/

License: MIT License

JavaScript 1.42% Python 94.97% CoffeeScript 0.07% LiveScript 0.02% TypeScript 0.18% CSS 1.27% HTML 1.17% EJS 0.23% Less 0.03% SCSS 0.06% Stylus 0.01% Jinja 0.57%

django-pipeline's Introduction

Pipeline

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.

django-pipeline's People

Contributors

cyberdelia avatar davidt avatar pelme avatar peymanslh avatar jwhitlock avatar asfaltboy avatar jezdez avatar estebistec avatar hsiaoyi0504 avatar chipx86 avatar ara818 avatar rdil avatar fdintino avatar kylemacfarlane avatar sassanh avatar nasirhjafri avatar leonardoo avatar camilonova avatar bryanchow avatar dcharbonnier avatar slafs avatar streeter avatar pdr avatar blankser avatar vbabiy avatar miki725 avatar dnerdy avatar kevinmarsh avatar svetlyak40wt avatar caioariede avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.