lesscss-maven-plugin
lesscss-maven-plugin copied to clipboard
imports
(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 (https://github.com/marceloverdijk/lesscss-java).
Resolving imports is done using a regexp pattern in https://github.com/marceloverdijk/lesscss-java/blob/master/src/main/java/org/lesscss/LessSource.java:
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?
^\s*(?!//)\s*@import\s+(url\()?\s*\"(.+)\s*\"(\))?\s*;.*$
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 this:
(?!\\s*//\\s*)
into this (now with double backslashes):
\\s*(?!//)\\s*
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):
^\\s*@import\\s+(url\\()?\\s*\"(.+)\\s*\"(\\))?\\s*;.*$
I'm seeing this issue as well - do you have a guess when this fix may be made? Thanks!
+1
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?
+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! =)
I will look into it. Simple quote imports is fixed for 1.3.3. I need to reproduce the issue with white spaces.
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.