Sea.js Manual & Documentation


Table of Contents


LESS Plugin

LESS is a dynamic stylesheet language. LESS extends CSS with dynamic behavior such as variables, mixins, operations and functions. LESS runs on both the client-side (IE 6+, Webkit, Firefox) and server-side, with Node.js.

With SeaJS, it is easy to code in LESS in the browser. Let's take an example.

First, using seajs.config to specify the path of less compiler and enable the less plugin by adding it to preload:

seajs.config({
  alias: {
    'less': 'less/1.1.5/less'
  },
  preload: ['plugin-less']
});

Then, just write your less files, and load them using require:

style.less:

@red: #f00;
@blue: #00f;

.red {
  color: @red;
}

.blue {
  color: @blue;
}

main.js:

define(function(require) {
  require('./style.less');
});

There is no more words of explanation.

Please see the online example: Coffee and LESS in SeaJS