Deniz Turgut 31ccbde072 teach plugins with dependencies to behave лет назад: 11
..
test_data c694cb404d move tests to plugin folder лет назад: 11
Readme.rst 9e70c17839 import plugins from core and restructure repo лет назад: 11
__init__.py 9e70c17839 import plugins from core and restructure repo лет назад: 11
assets.py 31ccbde072 teach plugins with dependencies to behave лет назад: 11
test_assets.py 31ccbde072 teach plugins with dependencies to behave лет назад: 11

Readme.rst

Asset management
----------------

This plugin allows you to use the `Webassets`_ module to manage assets such as
CSS and JS files. The module must first be installed::

pip install webassets

The Webassets module allows you to perform a number of useful asset management
functions, including:

* CSS minifier (``cssmin``, ``yui_css``, ...)
* CSS compiler (``less``, ``sass``, ...)
* JS minifier (``uglifyjs``, ``yui_js``, ``closure``, ...)

Others filters include gzip compression, integration of images in CSS via data
URIs, and more. Webassets can also append a version identifier to your asset
URL to convince browsers to download new versions of your assets when you use
far-future expires headers. Please refer to the `Webassets documentation`_ for
more information.

When used with Pelican, Webassets is configured to process assets in the
``OUTPUT_PATH/theme`` directory. You can use Webassets in your templates by
including one or more template tags. The Jinja variable ``{{ ASSET_URL }}`` can
be used in templates and is relative to the ``theme/`` url. The
``{{ ASSET_URL }}`` variable should be used in conjunction with the
``{{ SITEURL }}`` variable in order to generate URLs properly. For example:

.. code-block:: jinja

{% assets filters="cssmin", output="css/style.min.css", "css/inuit.css", "css/pygment-monokai.css", "css/main.css" %}

{% endassets %}

... will produce a minified css file with a version identifier that looks like:

.. code-block:: html



These filters can be combined. Here is an example that uses the SASS compiler
and minifies the output:

.. code-block:: jinja

{% assets filters="sass,cssmin", output="css/style.min.css", "css/style.scss" %}

{% endassets %}

Another example for Javascript:

.. code-block:: jinja

{% assets filters="uglifyjs,gzip", output="js/packed.js", "js/jquery.js", "js/base.js", "js/widgets.js" %}

{% endassets %}

The above will produce a minified and gzipped JS file:

.. code-block:: html



Pelican's debug mode is propagated to Webassets to disable asset packaging
and instead work with the uncompressed assets.

Many of Webasset's available compilers have additional configuration options
(i.e. 'Less', 'Sass', 'Stylus', 'Closure_js'). You can pass these options to
Webassets using the ``ASSET_CONFIG`` in your settings file.

The following will handle Google Closure's compilation level and locate
LessCSS's binary:

.. code-block:: python

ASSET_CONFIG = (('closure_compressor_optimization', 'WHITESPACE_ONLY'),
('less_bin', 'lessc.cmd'), )

.. _Webassets: https://github.com/miracle2k/webassets
.. _Webassets documentation: http://webassets.readthedocs.org/en/latest/builtin_filters.html