lesscss-maven-plugin rhino compiler warning

2013-10-31

Happened to notice a lot of duplication in a CSS file generated using the lesscss-maven-plugin. After some investigation, discovered it was because of a less file being imported more than once (although it wasn’t obvious looking at the code).

It appears that the Rhino less compiler that the lesscss-maven-plugin currently uses doesn’t track imports correctly, so it will effectively import a file multiple times, and add to the definitions of items defined.

Looking at the Github repo https://github.com/marceloverdijk/lesscss-maven-plugin, they are experimenting with the node.js based less compiler. Doing a comparison, it correctly handles multiple imports, and is also much faster.

So, until the lesscss-maven-plugin is finished the update to the node.js less compiler, be careful and ensure a given file is only imported once.

The project in question was using version 1.3.0 of the lesscss-maven-plugin, but I updated to the latest version (1.3.3 as of writing). This reduced the duplication, but it still doesn’t correctly handle a relatively simple case. Here’s an example.

main.less

1
2
@import ‘header’;
@import ‘footer’;

header.less

1
@import ‘mixins’;
1
@import ‘mixins’;

mixins.less

1
.test { color:red;}
The node.js compiler will produce the following:
1
.test {color:red;}

but the Rhino compiler produces:

1
2
.test {color:red;}
.test {color:red;}


Comments: