16

The update to v2.6 works from with VS 2012 and I have the Web Tools 2012.2 update installed, but a problem that I noticed that does not exist in the v2.5.1 version (I downgraded to fix for now) is that the @import lines in LESS files do not locate the referenced files anymore when compiling.

The compiler bombs unless the file referenced in the @import line is in the same physical folder. If any path information exists, such as "../../style/common.less", the compiler responds with an error and won't create the generated CSS file.

The error that I get is that it cannot find the file and the path information is truncated to either the first parent path construct or none. So, it's looking for "../style/common.less" or "style/common.less". It seems to be intermittent between the two.

For a possibly related issue, see: LESS importing CSS and relative paths

UPDATE: Confirmed that the expected behavior works correctly in LESS v1.3.1 and below.

I updated to v2.6 of Web Essentials via the Visual Studio extensions update dialog. Then I replaced the contents of the LESS script file in the path X:\Users\{USER}\AppData\Local\Microsoft\VisualStudio\11.0\Extensions\{HASH}\Resources\Scripts\less-1.3.0.js (which was v1.3.3 originally with the Web Essentials v2.6 update) with the scripts for versions 1.3.0, 1.3.1, 1.3.2, 1.4.0-beta, 1.4.0 and 1.4.1. The compiles only worked with versions 1.3.1 and lower.

I'm wondering if something got broken when support for @import-once was removed.

UPDATE 2: Version 2.7 of Web Essentials still exhibits this behavior, but can be fixed also as per above.

Community
  • 1
  • 1
Neil Monroe
  • 1,201
  • 1
  • 15
  • 20

2 Answers2

12

2.6 has the 1.3.3 version of the official LESS compiler. It might have a bug. I'll investigate this issue and release an update when I have a fix.

Thanks for reporting this!

UPDATE: FIXED!

This has now been verified and fixed for VS 2012 as of July 16, 2013.

Version 2.8 of Web Essentials addresses the issue in this question, so if you update again from within Visual Studio 2012 or by manually installing the extension you will be able to use the LESS compiler for relative @import statements.

It will only work with LESS 1.3.3 (the version packaged with the extension), but this shouldn't be an issue since it now works out-of-the-box.

To see what else was updated in v2.8 of the extension, check the change log: http://vswebessentials.com/changelog

Thanks to Mads Kristensen and the rest of the team that helped to fix this!

UPDATE: VS AUTO-UPDATE

v2.8.1 of the extension for VS 2013 pushed out to the Visual Studio Extension Gallery. You should get the VS auto-update message or go to "Tools > Extensions and Updates..." menu item and update from there.

Chris Hynes
  • 9,999
  • 2
  • 44
  • 54
Mads Kvist Kristensen
  • 2,610
  • 2
  • 18
  • 14
  • 2
    Hi, any news on this. I came across the same problem yesterday :( – Nick May 01 '13 at 10:36
  • 1
    Same problem here, used the OP fix but it would be nice to release an update. – Guillaume86 May 07 '13 at 14:54
  • Same problem. I have version less.js 1.3.0 and it works but only for relative path like '../'. If I add 2 folders back, '../../', it doesnt' work – Draykos May 30 '13 at 09:20
  • @Draykos, the file still must be named "less-1.3.0.js", but the contents are v1.3.3 out-of-the-box from the VS update. Only version 1.3.1 and below work correctly. Make sure the contents of the file contains the correct version of the code. – Neil Monroe May 31 '13 at 19:09
  • Import in 2.8 is massively broken for me now. I'll post a bug report. – Andre Loker Jul 17 '13 at 09:16
  • Regarding the comment above: if b.less imports a.less and c.less imports b.less, the output of c.less is empty. – Andre Loker Jul 17 '13 at 09:26
  • I'm seeing a problem similar to @AndreLoker. If multiple LESS files are importing the same file, the result of compilation can be empty. This broke as soon as I updated to to 2.8. – Anna Brenden Jul 17 '13 at 13:45
  • I managed to fix the most serious problems by following the suggestions by rjgotten: https://github.com/madskristensen/WebEssentials2013/pull/25#issuecomment-21098875 (requires manual modification of the plugin files) – Andre Loker Jul 17 '13 at 17:24
  • @EricBrenden: That should be fixed by https://github.com/madskristensen/WebEssentials2013/pull/30 – SLaks Jul 17 '13 at 17:44
  • @SLaks Thanks, waiting for the backport to 2012. – Andre Loker Jul 17 '13 at 18:18
  • @AndreLoker: You can backport the fix yourself by copying the new files over to the resources directory in the installed extension. (all that changes was the external JS & WSF files) – SLaks Jul 18 '13 at 13:34
  • import-once is also broken in 2.8 if your imported files ALSO contain similar import-ince references (which unfortunately, was the point) – cirrus Jul 24 '13 at 16:53
  • in VS2012 the current WebEssentials 3.0 still gives me wrong paths when my root "A.less" includes a "B/B.less" containing a relative url (like img1/1.png).. What I get in A.css (=the file I include in the page) is "url(img1/1.png)", which is the same I would get compiling B.less alone, while I was expecting "url(B/img1/1.png)". The latter works, the former does not. My current workaround is to replace the provided less-1.4.2.min.js with the older less-1.3.3.min.js and this at the moment works well.. – Luke Sep 18 '13 at 10:20
3

This is now fixed and released for VS 2013.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964