Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Asset management for Flask.

Project Description


.. contents::

.. include:: ../README.rst


* **Flask 0.8** (or later)

One of the following:

* **Java**: if you want to use `YUI Compressor`_.
* **NodeJS**: if you want to use `UglifyJS`_ or `clean-css`_.


* **LESS**: if you need to compile `LESS`_ files.

Installing YUI Compressor

To use `YUI Compressor`_ you must install Java. Once Java has been installed
make sure to set ``JAVA_BIN`` in your application config.

You can download YUI Compressor from
`<>`_ and make sure that
``YUI_COMPRESSOR_BIN`` points to the ``yuicompressor-x.y.z.jar`` file.


There are several configuration options available for **Flask-Funnel**:


A dict of CSS bundles:

.. code-block:: python

app.config['CSS_BUNDLES'] = {
'bundle1': (

Defaults to: ``{}``


A dict of JavaScript bundles:

.. code-block:: python

app.config['JS_BUNDLES'] = {
'the_bundle': (

Defaults to: ``{}``


This is the default value for the media attribute of the <link> tag for

Defaults to: ``'screen,projection,tv'``


The subdirectory of the static directory that the generated bundles are saved

Defaults to: ``'bundles'``


If you plan on using `YUI Compressor`_ you must set this variable.

*It has no default value.*


If you plan on using `YUI Compressor`_ you must set this variable.

*It has no default value.*


If you require `LESS`_ support you must point this to ``lessc``.

Defaults to: ``'lessc'``


If you want LESS files to be compiled when ``app.debug`` is ``True`` and
compressed files are not being used.

Defaults to: ``True``


If you want to use `UglifyJS`_ you must set this variable.

*It has no default value.*


If you want to use `clean-css`_ you must set this variable.

*It has no default value.*


If you are using `Flask-S3`_ you must set this to use Flask-S3's
``url_for()`` function.

Defaults to: ``False``

Including bundles in templates

To include a bundle in a template you can use the ``css()`` or ``js()``

.. code-block:: html+jinja

{# Jinja2 template #}
<!doctype html>
<title>The Title</title>
{{ css('bundle-name') }}
{{ js('bundle-name') }}

This will generate the appropriate markup for each bundle.

Note: When ``app.debug`` is ``True`` these will output markup for each file in
the bundle.

Media types for stylesheets

The ``css()`` function will, by default, generate ``<link>`` tags with a
``media`` attribute set to ``CSS_MEDIA_DEFAULT``. You can override this by
passing an optional second argument.

Using the manager to bundle and minify assets

The extension provides a sub-manager for `Flask-Script`_ which can be used as

.. code-block:: python

from flask.ext.script import Manager
from flask.ext.funnel.manager import manager as funnel_manager

manager = Manager(app)
manager.add_command('funnel', funnel_manager)

You can now use the manager to bundle and minify your assets using::

$ ./ funnel bundle_assets

This will create a ``bundle`` folder within the app's static folder to store the
bundled files. CSS bundles go into a ``css`` subfolder and JavaScript bundles go
into the ``js`` subfolder. Each of these subfolders will have a number of
``*-min.*`` files which are the compressed and minified versions of the bundles.

.. include:: ../CHANGELOG

.. include:: ../CONTRIBUTORS

.. _clean-css:
.. _Flask:
.. _Flask-S3:
.. _Flask-Script:
.. _GitHub:
.. _LESS:
.. _UglifyJS:
.. _YUI Compressor:

Release History

History Node


History Node


History Node


This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(41.0 kB) Copy SHA256 Hash SHA256
Source None Mar 13, 2013

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting