Description
By using @import (inline),
the source file is included in the output without processing. The inline is important when the CSS file is not Less compatible.
Even though Less supports the standard CSS, it does not support comments in some places without modifying the CSS. So, use this option to include the file in the output to get all the CSS in one file.
The @import (inline)
was released in version 1.5.0.
Syntax
@import (inline) “filename”;
Example
Below is the simple example explaining the use of @import (inline)
in less.
Step 1
Create a HTML file in the same Nodejs folder as shown below.
import_inline.html
[c]
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<title>Import Option Inline</title>
</head>
<body>
<h1>Welcome to SPLessons</h1>
<h3>Use of option inline</h3>
<p>By using @import (inline) the source file is included in the output without processing.
<br>The inline is important when the CSS file is not be a Less compatible.</p>
</body>
</html>
[/c]
Step 2
Now, create two Less files as shown below.
Import_inline.less
[c]
.style{
font-family: "Comic Sans MS";
font-size: 15px;
}
[/c]
style.less
[c]
@import (inline) "C:\Users\Samuel\nodejs\import_inline.less ";
p {
color:red;
}
[/c]
Step 3
Compile the above code in the command prompt by using the command.
[c]lessc style.less style.css[/c]
Step 4
By compiling the above .less file, it automatically generates .css file as shown below.
style.css
[c]
style{
font-family: "Comic Sans MS";
font-size: 15px;
}
p {
color: red;
}
[/c]
Result
After making all the required changes, run the html file in a browser to get the output.