LESS compile error ParseError: Syntax Error on line 1 - css

I am trying to do some customisation on my existing bootstrap less file by importing import my own less file into existing bootstrap.less.
I thought it would be simple, however I've spend painful couple hours already to try to make new less compiled.
every time I add my file in I got:
ParseError: Syntax Error on line 1 in C:\xxx\content\bootst
rap\less\xxx.form.less:9:999 8 }
My own less file:
.form-unit {
background-color: #F5F5F5;
border-radius: 6px 6px 6px 6px;
margin-bottom: 30px;
padding: 10px;
min-height: 170px;
position:relative;
}
Anyone have same problems? what did i missed???
I compiled it online not surprisingly it works, I am so confused

Are you using SimpLESS as your LESS compiler? If so there's a bug where it can't read files encoded in UTF-8 with BOM. Just convert your file to UTF-8 without BOM and it will work.

To anyone using Visual Studio and continuing to tear their hair out with the problem above (I've been in the same boat for the last hour or so, and the approved answer above didn't work for me), I'd recommend getting hold of the Web Essentials extension.
It allows for instant compilation of LESS files into minified CSS whenever they are saved in much the same way as SimpLESS does. No complaints about encoding, line endings or anything else!

For all .less files used in Visual Studio, you need to change the UTF encoding....
File > Advanced Save Options...
Set "Encoding" to "Unicode (UTF-8 without signature) - codepage 65001
Once you do this, the Simpless compiler will work for your files.

If you are using Visual Studio, make sure that you didn't accidentally add the included file to the compile list. Check compilerconfig.json and make sure you aren't trying to compile both the main SASS file and the included one.

Related

Live Sass Compiler does not correctly prefix VSCode [duplicate]

I have an issue with the Live Sass compiler in VS Code, namely when working with lists. None of the usual operations work. In the following example, it's list.nth(list,index).
The following works fine in a Codepen:
HTML
<p>red</p>
<p>blue</p>
<p>green</p>
SCSS
#use "sass:list";
p {
font-size: 25x;
font-weight: bold;
}
$colors: red blue green;
#for $n from 1 through 3 {
p:nth-child(#{$n}) {
color: list.nth($colors,$n);
}
}
This also works fine when compiling it locally with the Dart Sass CLI.
But when I try to compile this with the Live Sass compiler in VS Code, I get the following error:
Compilation Error
Error: Invalid CSS after "... color: list": expected expression (e.g. 1px, bold), was ".nth($colors, $n);"
Why is that?
Use Live Sass Compiler by Glenn Marks
I had exactly the same problem. You read the SASS official website, follow the instructions, write the code in Visual Studio Code, and then you get this strange Compilation Error when saving the SASS or SCSS file. You double-check everything and it seems like it should work, but it doesn't.
Well, the problem is caused by the Visual Studio Code extension you are using for compiling SASS or SCSS files to CSS files.
Don't use this extension: Live Sass Compiler by Ritwick Dey
You are probably using this extension: Live Sass Compiler by Ritwick Dey. It's widely used, but is no longer supported by the author. Consequently, the SASS version isn't updated. This extension produces the error you are describing.
Use this extension: Live Sass Compiler by Glenn Marks
You should use this extension: Live Sass Compiler by Glenn Marks. As the author states: A big thank you to #ritwickdey for all his work. However, as they are no longer maintaining the original work, I have released my own which has been built upon it. This extension compiles your SASS or SCSS files to CSS files successfully.
The extension you are using does not seem to be maintained anymore, you can try to use this one instead.

MVC - LESS not compiling properly

I am trying to compile a LESS file to CSS. The same lines of code is compiling perfectly fine in online tools. Tried it in around 5 tools. But for the same thing it is breaking in my code.
I have a mixin which is using unit.
.mixinbgwcollleftmenu(#mixinbgwcollleftmenupt){
display: inline-block;
line-height: normal;
vertical-align: bottom;
width: 100%;
padding-top: unit(#mixinbgwcollleftmenupt, vh);}
When I use this, I am getting the error. Expected '}' but found 'i' on line 634 in file But when I try to remove that line of code, and just write it simply, the whole app is breaking, and I am getting the error in the picture.
Things I have tried.
The app was running dotless on visual studio, I uninstalled it. I tried compiling it on client side via the CDN, same error.
I removed the unit line of code, and hard coded it for testing. The special characters show up.
And when the special characters come up, I get a 500 error altogether.
I removed the line of code and the variable in the function altogether, and the same characters appear.

LESS in Visual Studio 2015

I have downloaded and imported the font-awesome in my MVC project. I am using the .less files for styling.
I have a different less file for styles which runs fine but for some reason the font-awesome less file is not working, it gives the following error:
variable #fa-font-size-base is undefined on line 6 in file 'core.less':
[5]: display: inline-block;
[6]: font: normal normal normal #fa-font-size-base/#fa-line-height-base FontAwesome; // shortening font declaration
-----------------------------^
[7]: font-size: inherit; // can't have font-size inherit on line above, so need to override
I am not importing any file in the other less files, but seems like font-awesome has a bunch of imports. Can anyone help?
I ran into a very similar error which brought me here.
In my case, the problem was that I was using an out-date version of the dotless compiler (http://www.dotlesscss.org/)
We had been using an older version of Font Awesome and after upgrading it would no longer compile to CSS due to that missing variable. The newest version (as of this posting) had corrected whatever was causing the compilation failure. After upgrading the version of dotless we used, the problem went away.
Even if you're not using dotless, might be worth determining which .less compiler you are using to see if a newer version is available.

LESS: Unrecognised input

I'm trying to learn less with the help of Web Essentials 2012.
Right from the start, this LESS code:
#main-color: red;
.mega-warning {
font-size: 24px;
color: #main-color;
}
is giving a compile error "LESS: Unrecognised input" and the compilation stops. When i declare the variable #main-color inside the .mega-warning class scope everything works:
.mega-warning {
#main-color: red;
font-size: 24px;
color: #main-color;
}
What am i missing?
I'm struggling with the very same issue. Looks like Web Essentials 2012 v2.9 for some reason is not very happy about *.less files starting with variable declaration. Here is my workaround:
html{}
#main-color: red;
.mega-warning {
font-size: 24px;
color: #main-color;
}
Strangely enough things work absolutely fine when using standalone lessc 1.4.2 compiler (which is included in WE2012 2.9 as per changelog). I've sent an email to the author of Web Essentials extensions and posted him a link to this question, so hopefully he'll address it pretty soon.
Save less files with encoding "UTF-8 without BOM". This approach was proposed in the post
VS 2012 Web Essentials Less Compile Error
I had this issue in VS / Web Essentials 2013. My fix was to recreate the .less file using a template. I had originally just changed the extension from .css to .less, but apparently that doesn't work. So use the Visual Studio template for a .less file instead.
I'm not positive where that .less template came from though, it might have come with Web Essentials, or it may have come in the SideWaffle template pack.
Try this Where you have added reference to less file:
rel="stylesheet/less"
With this your reference will look like
<link rel="stylesheet/less" type="text/css" href="styles.less" />
Download less.js and add the <script> tag referencing it in the <head>. The css <link> should come before the <script>.

simpLESS not compiling

I am using 'simpLESS' program to compile my .less files into .css files on the fly.
It is really great!
However, after using it only for couple of days, 'simpLESS' stopped copiling the .less into .css files.
I have tried to reinstall, redownload and then reinstall, tried other directories, other .less files, tried recompiling manuall - but nothing works.
Has anyone experienced this?
Thanks!
Simpless is always bad with error handling! instead of telling you what's wrong it just doesn't work! So here is what I do: when Simpless doesn't display the error I use Winless to find the error and after I fix it I go back to Simpless.
note: I use Simpless because it works fine with #import .less files in the other hand Winless doesn't.
I seem to found the problem.
I had the following code:
#result{
.result_padding;
.icon{
height: 17px;
width: 23px;
}
}
However, the ".result_padding" actually was not defined. The simpLESS compiler should have spotted this, but I guess this is a bug. Anyway, after removing this line - it worked.

Resources