Original address: http://www.dotblogs.com.tw/ajun/archive/2012/07/20/73519.aspx?fid=42162
This article does not introduce less is what, only record how to prepare to use command-line to compile the *.less environment under Windows.
Install Node.js
Download the MSI installation file directly from the Node.js Web site and perform the installation.
Install less through NPM
NPM is the Packagemanaer of Node.js, the program can be used after installing Node.js.
So just install less through NPM This package is OK.
First executes the Node.js command prompt and executes under the command window that opens
NPM Install Less-g
Less's official website shows that it is the direct use of npminstall less, but in order to facilitate the use of LESSC,
So it is recommended to add-G to install it into global package
After executing the instruction, you can use LESSC when it is finished.
Compiling *.less with LESSC
Under the Node.js Command Prompt window, switch to the *.less file directory you want to compile.
Then execute the following instructions
LESSC filename.less > Filename.css/non-compression
LESSC filename.less >filename.css-x//compression
After execution, the specified CSS file is generated in the directory
Other:
browser-side use
Lesscss can also be used without compilation, directly on the browser side.
How to: Download Lesscss. js files, such as Lesscss-1.4.0.min.js.
Introduce. Less files in the page
<link rel= "stylesheet/less" href= "example.less"/>
Note that the value of the Rel property is stylesheet/less, not stylesheet.
Introduction of the. js file in step 1th download
<script src= "Lesscss-1.4.0.min.js" ></script>
Of particular note is that because the browser side uses Ajax to pull the. Less file, it is not able to pull the. Less file directly when the native file system is open (that is, the address is file://) or if there is a cross-domain, resulting in the style not taking effect.
There is also a situation that can easily lead to a style that does not work, that is, some servers (mostly IIS) will return 404 to a file with an unknown suffix, resulting in the inability to read the. less file normally. The solution is to configure the MIME value for the. less file in the server as TEXT/CSS (search for the exact method). Or there is a simpler way to rename the. Less file directly to the. css file.