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?
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:
- place
link
tag beforescript
tag - set
rel
to“stylesheet/less”
- be aware of bug in chrome
Include less file in your html and use some server if u r using google chrome.
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.
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.
来源:https://stackoverflow.com/questions/10554462/how-can-i-compile-less-files-within-browser