Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LESS parsing doesn't work #1716

Open
FWest98 opened this issue Dec 27, 2014 · 9 comments
Open

LESS parsing doesn't work #1716

FWest98 opened this issue Dec 27, 2014 · 9 comments

Comments

@FWest98
Copy link

FWest98 commented Dec 27, 2014

Similiar to the fixed #1665 , LESS doesn't parse in my setup.
I have Visual Studio Update 4 with WE 2.5.3, in which the parsing should be working again, but it doesn't. When I save the file, or build the solution, I get the following output in the "Output"-window:
"Less: Compiling [file].less"
The status bar at the bottom of the windows shows "Compiling 0 dependent file for", but nothing happens.
The preview pane shows "Compilation Error occurred (see error list to navigate to the error location):"

I already tried to reinstall Web Essentials, downgrading to 2.5 also doesn't work.

Visual Studio Premium 2013, 12.0.31101.00 Update 4
.NET Framework 4.5.51641
Web Essentials 2.5.3
Resharper 9 Update 1 (9.0.20141219.130142)
dotCover 3.0 Update 1 (3.0.20141219.140120)
dotMemory 4.2 Update 1 (4.2.20141219.130159)
dotTrace 6.0 Update 1 (6.0.20141219130145)

@LukaRadovanovic
Copy link

Hi, i've got a same problem. Did you find fix for it?

@FWest98
Copy link
Author

FWest98 commented Jan 14, 2015

I ended up installing WinLESS and adding a watch to my less files. It compiles automatically on save and shows a popup with the status (succeeded/failed).
But I hope this issue can be fixed in an upcoming version. In a previous commit I saw "All NodeJS-baed tools removed", and the LESS-compiler is NodeJS-based. Does that mean the compiler is removed from WE?

@DotNetSparky
Copy link
Contributor

Hey guys, I was having a similar problem all of the sudden (started about a week ago when I did a clean install of the extension). I tracked it down to a bug in less.js. (I just submitted a fix to them last night). Less.js isn't stripping the BOM in imports, so (assuming you had an import in your file) you'd end up with a file that had illegal BOM bytes in the middle of it. Besides causing random syntax errors, it would downright crash autoprefixer in a way that didn't give any error messages to WebEssentials.

Out of curiousity, if you have autoprefixer enabled (Tools -> Options -> Web Essentials -> CSS --> Enable Autoprefixer), try turning that off and see if you get a different result.

I'll post here shortly a way to patch less.js to fix the underlying problem.

@madskristensen
Copy link
Owner

@FWest98 the compilers are not being removed from WE2013 - only for WE2015

@FWest98
Copy link
Author

FWest98 commented Jan 14, 2015

@madskristensen and why is it removed from WE2015? Is it integrated in Visual Studio?

@madskristensen
Copy link
Owner

WE cannot provide the flexibility often needed for compiling and this is also an area that causes the most issues. You can see more about why this is and what to use instead here http://channel9.msdn.com/Shows/Web+Camps+TV/Modern-Web-Development-Tools-in-Visual-Studio-2015-with-Mads-Kristensen

@DotNetSparky
Copy link
Contributor

Here's a fix you can try for less.js to fix the BOM import issue I mentioned:

First, locate where WebEssentials is installed (this is the fun part)... Should be %localappdata%\Microsoft\VisualStudio\12.0\Extensions\ + a random name
(look in each of the Extensions folders until you see one that has a WebEssentials2013.dll).

Inside this folder, navigate to and open (with a text editor): Resources\Tools\node_modules\less\lib\less\import-manager.js

Do a search for "function(loadedFile)" (should be around line 69 or so), you should see these 3 lines:

var loadFileCallback = function(loadedFile) {
var resolvedFilename = loadedFile.filename,
    contents = loadedFile.contents;

Replace that last line (contents = loadedFile.contents) with:

    contents = loadedFile.contents.replace(/^\uFEFF/, '');

If you have Visual Studio open, exit and start it again.

@FWest98
Copy link
Author

FWest98 commented Jan 14, 2015

Unfortunately, that didn't fix my problem.
But even with a newly created file I had this problem, so it was unlikely to be BOM. But no, didn't work.

@am11
Copy link
Contributor

am11 commented Jan 18, 2015

For the BOM issue, you can put @charset "UTF-8"; at the beginning of the less file and it will work properly. This usually happens when you Ctrl+click-drag an existing .less file in Solution Explorer to create a new one. I blame VS for putting BOM in first place. Thanks @DotNetSparky for fixing this issue where it belongs: less/less.js#2391 👍

Secondly, the error you are having could be due to many reasons. So maybe the following facts (behaviours) would give you some idea what is going wrong in your setup:

  • Filenames starting with _ are considered as partials and do not compile independently. If the chained compilation is enabled, it will compile all the callers of this partial. If there is none, you will get no output.
  • If you have .weignore file somewhere in your directory structure (or home directory: %UserProfile%), you may want to alter the rules there. Even though we tried to make it bullet prove, it is showing some funny behaviour lately (in some mysterious use-cases).

Tidbit: do not rely to much on the message Compiling {0} dependent files for in status bar too much, sometimes it just lie and the result is still produced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants