Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.
vijaykiran edited this page Apr 19, 2012 · 2 revisions

Play LESS module

The LESS module allows you to use LESS stylesheets in your Play application, without having to manually compile them to CSS.

Usage

Add the less module to your application.conf:

module.less=${play.path}/modules/less

Now any file in your public/ directory that ends in .less is automatically processed by the plugin, and outputted as CSS.

Example Create a file called public/stylesheets/style.less, with contents:

@color: red;
h1 {
  color: @color;
}

Now, add the stylesheet to your main template in app/views/main.html:

<link type="text/css" rel="stylesheet" href="@{'public/stylesheets/style.less'}" />

Caching

The less module sets and listens to Last-Modified and ETag headers, so most browsers will retrieve the file only once. At the server, a compiled CSS file is stored in the cache, and automatically invalidated when the less file changes, or when one of the imported files change. So you can change your less files even while Play is running in production mode.

Notes

In case of an error in your less file, the error will be shown on your page to help you debug.

Clone this wiki locally