13

I created code for switching themes using LESS functionality. Unfortunately the LESS files will not compile in browser. How can I compile LESS files within browser?

doelleri
  • 19,232
  • 5
  • 61
  • 65
Pawan
  • 31,545
  • 102
  • 256
  • 434

4 Answers4

14

This is a piece of documentation:

Client-side usage

Link your .less stylesheets with the rel set to “stylesheet/less”:

<link rel="stylesheet/less" type="text/css" href="styles.less">

Then download less.js from the top of the page, and include it in the <head> element of your page, like so:

<script src="less.js" type="text/javascript"></script>

Make sure you include your stylesheets before the script.

So, you need to:

  1. place link tag before script tag
  2. set rel to “stylesheet/less”
  3. be aware of bug in chrome
Community
  • 1
  • 1
ie.
  • 5,982
  • 1
  • 29
  • 44
  • if I follow the documentation, everything works well in FF. could you provide the completed non-working sample? – ie. May 11 '12 at 16:18
  • ok, I see, everything is more complicated then I thought before.. I'll try to reproduce the issue and will let you know if I find something – ie. May 11 '12 at 16:25
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/11158/discussion-between-yyy-i-777-and-ie) – Pawan May 11 '12 at 16:26
2

Include less file in your html and use some server if u r using google chrome.

user2327502
  • 191
  • 1
  • 4
1

you have to use some web server like apache tomcat, uniform server UPX etc in order to compile less in IE. as @ie told include those files in your document before running it in localhost.

JSAddict
  • 12,407
  • 7
  • 29
  • 49
0

Check your web server. Many servers are not initially set up to handle serving LESS files. Specifically newer versions of IIS tend to block serving *.less and need to be configured to do so. You can see if this is happening by loading your LESS CSS file directly from your browser. The easiest way to do that from Firefox is to view your page source and click the link to your LESS file.

Nathan Strutz
  • 8,095
  • 1
  • 37
  • 48