Re-compiling the skin's LESS

Hello!

In the context of adding some new user-level UI parameters (for the update to the accessibility user preference), I am trying to update less variables from the skin locally.
E.g. change the @font-size-base property and have it reflect on the whole UI as soon as the users validates the parameter on its profile.
However, I can’t figure out how to force a re-compilation of the LESS for the skin. In a stylesheet extension object with parsing ON, I tried using $services.lesscss.clearCacheFromSkin($xwiki.getSkin())​, however this does not seem to work properly (the SSX fails to load).
The changes themselves are somewhat working: when I just trigger the ColorThemeListener to re-compile the LESS by saving the current colorSkin, I get the expected result. So it’s only a matter of forcing the recompilation of the LESS from a script.
Do you think I’m on the right way? Do you know of an utility somewhere which would make this step easier?
Thank you in advance :slight_smile:
Lucas C.

PS: it would also be useful to be able to test out changes in some LESS just by refreshing a page and not have to re-save the current colorTheme just to refresh the cache

I’m personally using using the following steps:

  1. copy or link the less files I want to update
  2. call $services.lesscss.clearCache()
  3. Hard Refresh the page

Hope that helps.

I’m not aware of a mechanism to fully deactivate less caching though.

1 Like