- Language Features
- Less - Nested Rules
- Less - Nested Directives and Bubbling
- Less - Operations
- Less - Escaping
- Less - Functions
- Less - Namespaces and Accessors
- Less - Scope
- Less - Comments
- Less - Importing
- Less - Variables
- Less - Extend
- Less - Mixins
- Less - Parametric Mixins
- Less - Mixins as Functions
- Less - Passing Rulesets to Mixins
- Less - Import Directives
- Less - Import Options
- Less - Mixin Guards
- Less - CSS Guards
- Less - Loops
- Less - Merge
- Less - Parent Selectors
- Less - Misc Functions
- Less - String Functions
- Less - List Functions
- Less - Math Functions
- Less - Type Functions
- Less - Color Defination Functions
- Less - Color Channel Functions
- Less - Color Operation
- Less - Color Blending Functions
- Less - Command Line Usage
- Using Less In The Browser
- Less - Browser support
- Less - Plugins
- Less - Programmatic Usage
- Less - Online Compilers
- Less - GUIs
- Less - Editors and Plugins
- Less - Third Party Compilers
- Less - Frameworks
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
LESS - Command Line Usage
Using the command line, we can compile the .less file to .css.
Installing lessc for Use Globally
The following command is used to install lessc with npm(node package manager) to make the lessc available globally.
npm install less -g
You can also add a specific version after the package name. For example npm install email@example.com -g
Installing for Node Development
The following command is used to install the latest version of lessc in your project folder.
npm i less -save-dev
It is also added to the devDependencies in your project package.json.
Beta releases of lessc
It is tagged as beta when the lessc structure is published to npm Here, the new functionality is developed periodically. less -v is used to get the current version.
Installing an unpublished development version of lessc
The commit - ish is to be specified, when we proceed to install an unpublished version of lessc and the instructions need to be followed for identifying a git URL as a dependency. This will ensure that you are using the correct version of leesc for your project.
Server-Side and Command Line Usage
bin/lessc includes binary in the repository. It works with Windows, OS X and nodejs on *nix.
Command Line Usage
Input is read from stdin when source is set to dash or hyphen(-).
lessc [option option = parameter ...]
For instance, we can compile .less to .css by using the following command −
lessc stylesheet.less stylesheet.css
We can compile .less to .css by and minify the result using the following command.
lessc -x stylesheet.less stylesheet.css
Following table lists out options used in command line usage −
|Sr.No.||Options & Description||Command|
Help message is displayed with the options available.
lessc -help lessc -h
It includes the available paths to the library. These paths can be referenced simply and relatively in the Less files. The paths in windows are separated by colon(:) or semicolon(;).
lessc --include-path = PATH1;PATH2
It generates a makefile import dependencies list to stdout as output.
lessc -M lessc --depends
It disables colorized output.
No IE Compatibility
It disables IE compatibility checks.
It checks the syntax and reports error without any output.
lessc --lint lessc -l
It forcibly stops the display of error messages.
lessc --silent lessc -s
It force evaluates imports.
Allow Imports from Insecure HTTPS Hosts
It imports from the insecure HTTPS hosts.
It displays the version number and exits.
lessc -version lessc -v
It helps in removing the whitespaces and compress the output.
lessc -x lessc --compress
Source Map Output Filename
It generates the sourcemap in less. If sourcemap option is defined without filename then it will use the extension map with the Less file name as source.
lessc --source-map lessc -source-map = file.map
Source Map Rootpath
Rootpath is specified and should be added to Less file paths inside the sourcemap and also to the map file which is specified in your output css.
lessc --source-map-rootpath = dev-files/
Source Map Basepath
A path is specified which has to be removed from the output paths. Basepath is opposite of the rootpath option.
lessc --source-map-basepath = less-files/
Source Map Less Inline
All the Less files should be included in the sourcemap.
Source Map Map Inline
It specifies that in the output css the map file should be inline.
Source Map URL
A URL is allowed to override the points in the map file in the css.
lessc --source-map-url = ../my-map.json
It sets paths for URL rewriting in relative imports and urls.
lessc -rp=resources/ lessc --rootpath=resources/
In imported files, the URL are re-written so that the URL is always relative to the base file.
lessc -ru lessc --relative-urls
It processes all Math function in your css. By default, it's off.
lessc -sm = on lessc --strict-math = on
It allows mixed units.
lessc -su = on lessc --strict-units = on
A variable is defined which can be referenced by the file.
lessc --global-var = "background = green"
This is unlike global variable option; it moves the declaration at the end of your less file.
lessc --modify-var = "background = green"
To move on to every URL, an argument is allowed to specify.
lessc --url-args = "arg736357"
Inline source-mapping is generated.
lessc --line-numbers = comments lessc --line-numbers = mediaquery lessc --line-numbers = all
It loads the plugin.
lessc --clean-css lessc --plugin = clean-css = "advanced"