imports #4

iframeskills opened this Issue May 24, 2012 · 13 comments


None yet

9 participants


(thanks for the great plugin! small issue below:)

@media screen {
  @import "homepage.less";
  @import "searchresults.less";

-> fails

@media screen {
@import "homepage.less";
@import "searchresults.less";

-> does not fail.

Whitespace before imports seem to break compilation

/*@import "homepage.less";*/

also breaks. blocklevel comments and imports don't get along either.


Hi @iframeskills,

I know imports can be a little bit cranky...
The lesscss-maven-plugin uses my lesscss-java library (

Resolving imports is done using a regexp pattern in

private static final Pattern IMPORT_PATTERN = Pattern.compile("^(?!\\s*//\\s*)@import\\s+(url\\()?\\s*\"(.+)\\s*\"(\\))?\\s*;.*$", MULTILINE);

I think this needs a little bit of tweaking...


Perhaps this is a better regex?


And as for the block comments, it's always better to filter them out before parsing the file.


Good point about filtering block comments before parsing; I will definitely add that!

Honestly, I'm very bad at reg exp, can you maybe explain your changes?


I just changed the first part


into this (now with double backslashes):


What it does: The \s* allows whitespace, and the (?!//) disallows line comments.
What you had before did not allow whitespace at all.

Thanks for the great plugin by the way :)


And you could even omit the line comment part, since the whitespace rule will already filter it out.
This would then be the regex (with double backslashes):


I'm seeing this issue as well - do you have a guess when this fix may be made? Thanks!



I just got caught out as well.


I was waiting for a next less version...


You might as well incorporate single quotes into the regex, as this is also valid:

@import 'file.less';

Regexes aside, have you considered not tying lesscss-java releases strictly to less.js?

rweng commented Dec 3, 2012

+1 to singe quotes in regex. This broke my build.


+1 This just got me too. Was about to file an issue after tracking it down, only to realize I should have read this one first! =)

@paulfairless paulfairless referenced this issue in paulfairless/grails-lesscss-resources Jan 21, 2013

@import appears broken #26

@cpopov cpopov was assigned Mar 1, 2013
cpopov commented Mar 1, 2013

I will look into it. Simple quote imports is fixed for 1.3.3. I need to reproduce the issue with white spaces.

cpopov commented Mar 3, 2013

normally lesscss.js manages imports. But I am not sure how it will work in a Rhino environment. I am just thinking that if lesscss.js manages imports, maybe we shouldn't do a pre-processing with regexps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment