9

For better organization, I have a main .less file that imports other .less files using the @import syntax. In order for the Web Essentials Preview window to work I also have @import-once at the top of each .less file that imports the variables.less file.

This solution worked wonderfully until I upgraded to Web Essentials 2.8. Now I'm unable to import any .less file that has @import or @import-once declared in it. My main .less file no longer compiles.

If I remove the @import-once statements, the preview window is useless since I can't see the compiled CSS without importing my variables file.

I also had a case where I imported a .less file into a ruleset, as defined by lesscss.org in the Importing into ruleset section. This also no longer works since the upgrade to v2.8.

Has anyone else experienced these issues or have a resolution?

Thanks

2 Answers2

9

This seems to be a bug -> Feature in the latest version of the WebEssentials because of a new feature in Less 1.4.0. as Anwar describes. See the changelog of Less:

1.4.0 Beta 1 & 2 (2013-03-07)

  • default behaviour of import is to import each file once. @import-once has been removed.

Either

Update your files to use the new syntax (remove the -once from your imports)

Or

To use the older version of the engine, download the previous (2.7) version and don't update until you know it has been fixed.

Or

Or you can configure your Visual Studio to look at the Nightly Build feed from Web Essentials to download the very latest version (caution, nightly builds may contain other bugs or stop working from time to time). TO do so go to Tools -> Options -> Extensions & Updates and add the feed: http://vswebessentials.com/nightly/feed.ashx

Which seems to add a workaround that makes it work with the old syntax as well. Add WebEssentials Nightly feed

Community
  • 1
  • 1
jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • Here is a link to the 2.7 install if anyone needs it http://vswebessentials.com/nightly/webessentials2012-2.7.vsix – Phil Hale Jul 25 '13 at 15:23
  • I get an error saying "The extension manifest is invalid." Has anyone else had success opening this file? – Evan Portwood Jul 26 '13 at 13:47
  • Evidently my file association for .vsix was broken. I was able to install the extension by running "\Common7\IDE\vsixinstaller.exe " – Evan Portwood Jul 26 '13 at 15:08
3

In Less v1.4.0 @import-once has been removed and @import imports once by default. This means that with the following

@import “file.less”; @import “file.less”;

The second file is ignored.

I think that one is causing issue with import statements.

Anwar Javed
  • 325
  • 3
  • 11
  • I agree that v1.4.0 changed the way @imports works, but the problem with Web Essentials seems to be that a less file cannot import another less file that imports other less files. For instance, main.less cannot import foo.less that imports mixins.less and variables.less. The reason I want to import mixins and variables is so that when working with a less file I can preview the compiled css using the Web Essentials Preview window. If I don't import them, the preview window is useless since it can't find the referenced variables and mixins. – Evan Portwood Jul 26 '13 at 13:49