LESS Module

Version 19.1 by Guillaume Delhumeau on 2014/10/23 16:19

cssAdd the ability to use the LESS preprocessor in XWiki
TypeJAR
Category
Developed by

XWiki Development Team

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Enterprise

Compatibility

Since 6.1

Description

This modules offer a Java integration of LESS CSS, using the LESS CSS Compiler for Java.

It is also able to compile, at runtime, LESS files located into the current skin directory, in the WAR.

Presentation

You can read this presentation that we have made to introduce LESS and how to use in XWiki.

Components

This module provides 4 main components:

  • LESSCompiler: allows you to compile some LESS code, with some options. The CSS generated is minified.
  • LESSSkinFileCompiler: allows you to compile some LESS file located in the directory of any skin in the web-application. Velocity is executed before the LESS compiler is used, and every @imports will be checked on the /less directory inside the current skin. The results is cached and shared to every users, so you should not put velocity code which is context-dependent.
  • LESSSkinFileCache: caches the results compiled with the previous component. You can clear it when it is needed.
  • LESSColorThemeConverter: compute a color theme compatible with the Color Theme Application from a LESS file.

Script Services

This modules offer a script services called $services.lesscss.
It provides some functions to compile a skin file, compute a color theme from a LESS file, and to clear the cache.

Cache Strategy

Every LESS files compiled in XWiki is cached. The cache is cleaned each time a color theme is created, updated or deleted in a wiki. There is one cache per couple color theme/filesystem skin.

Before XWiki 6.2.3 and XWiki 6.3M2, there were only one cache per wiki. This means that if a color theme was saved on a wiki A, the cache was not cleared on the wiki B, even if the color theme was used in the wiki B. See XWIKI-10776.

By default, the cache is cleaned at the wiki start-up. If you want to keep the cache of the previous runtime (for performances reasons), you could add the following settings in xwiki/WEB-INF/cache/infinispan/config.xml:

<!-- LESS CSS cache -->
<namedCache name="lesscss.skinfiles.cache">
 <loaders>
   <loader class="org.infinispan.loaders.file.FileCacheStore" purgeOnStartup="false">
     <!-- Let XWiki cache module set the proper location -->
   </loader>
 </loaders>
</namedCache>
Tags:
    

Get Connected