diff --git a/docs/plugins.rst b/docs/plugins.rst index 7e09810b..bbeb5930 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -183,10 +183,19 @@ The above will produce a minified and gzipped JS file: Pelican's debug mode is propagated to Webassets to disable asset packaging -and instead work with the uncompressed assets. However, this also means that -the LESS and SASS files are not compiled. This should be fixed in a future -version of Webassets (cf. the related `bug report -`_). +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 diff --git a/pelican/plugins/assets.py b/pelican/plugins/assets.py index b5d1cf76..877373f6 100644 --- a/pelican/plugins/assets.py +++ b/pelican/plugins/assets.py @@ -36,6 +36,10 @@ def create_assets_env(generator): assets_src = os.path.join(generator.output_path, 'theme') generator.env.assets_environment = Environment(assets_src, assets_url) + if 'ASSET_CONFIG' in generator.settings: + for item in generator.settings['ASSET_CONFIG']: + generator.env.assets_environment.config[item[0]] = item[1] + logger = logging.getLogger(__name__) if logging.getLevelName(logger.getEffectiveLevel()) == "DEBUG": generator.env.assets_environment.debug = True