https://blog.teamtreehouse.com/install-node-js-npm-windows
Once you have Node JS installed on your machine, test the installation:
npm -version
If this command is successful, you will see the installed version.
In your working folder, place a LESS file named simple.less. For example, you can use this LESS code:
@primarycolor: #FF7F50;
@color:#800080;
h2{
color: @primarycolor;
}
h3{
color: @color;
}
Next, create an HTML file named index.html:
<head>
<link rel="stylesheet" href="simple.css" type="text/css" />
</head>
<body>
<h2>A simple example of Less</h2>
<h3>Hello World</h3>
</body>
</html>
In this working folder, you have a simple.less and index.html. In the HTML file, notice the reference to simple.css. This file is produced by compiling the LESS file into a CSS file. To compile the LESS file into a CSS file, use this command:
lessc simple.less simple.css
In your working folder, you will now have simple.css.
h2 {
color: #FF7F50;
}
h3 {
color: #800080;
}
Open the HTML in a browser, and you will see the rendered HTML with the CSS.
You have now learned how to compile a LESS file into a CSS file by using Node JS.
No comments:
Post a Comment
If you have any doubts or questions, please let us know.