Compiling the less source file with the command line requires node. js to be installed, official: http://nodejs.org/
Installing the less compiler using the NPM package management tool
NPM Install Less-g
The parameter-G is a directive installed in all environments, and if you want to install only a specific version, use the following command
NPM install [email protected]-G
Less compiler usage:
< Source > [Destination]
Example:
E:\Dev\Dev2015\less compile dir>lessc bootstrap.less bootstrap.css
This will produce a. css file
Compressed output File size
Lessc-x bootstrap.less Bootstrap.css
By using the-x parameter, the size of the output file is compressed, and the following is the file size before and after compression
-X compression is primarily to remove redundant whitespace implementations
Get help
LESSC--help
Or
Lessc-h
List of dependencies for other commonly used command output guidance files
-M,--depends Outputs a Makefile Import dependency list to stdout.
Disable color
--no-color disables colorized output.
Disable IE compatibility check
--no-ie-compat disables IE compatibility checks.
Disable JavaScript
--no-js disables JavaScript in less files
Grammar check
-L,--lint Syntax Check Only (lint).
Ignore warning messages
-S,--silent suppresses output of error messages.
--strict-imports forces evaluation of imports.
Allow import of unsecured HTTPS hosts
--insecure allows imports from insecure HTTPS hosts.
Use of plugins
--plugin=plugin=options Loads a plugin. You can also omit the--plugin= if the plugin begins Less-plugin. e.g. the clean CSS plugin are called Less-plugin-clean-css once installed (NPM install less-plugin-clean-css), use Eith Er with --plugin=less-plugin-clean-css or just--clean-css specify options afterwards e.g.--plugin= Less-plugin-clean-css= "Advanced" or--clean-css= "advanced"
Installing plugins
npm Install Less-plugin-clean-css [Email protected] node_modules\less-plugin-clean-css└──[email protected] ([email protected], [email protected]) PS e:\ Dev\dev2015\less Compile dir>
Output compression using the Less-plugin-clean-css plugin
LESSC--plugin=less-plugin-clean-css. \bootstrap.less bootstrap.css
View version
-V,--version Prints version number and exit.
--source-map[=filename] Outputs a v3 sourcemap to the FILENAME (or output Filename.map). --source-map-rootpath=x Adds This path onto the sourcemap filename and less file paths. --source-map-basepath=x sets Sourcemap base path, defaults to current working directory. --source-map-less-inline Puts the less files into the map instead of referencing them. --source-map-map-inline Puts the map (and any less files) as a Base64 data URI into the output CSS file. --source-map-url=url sets a custom URL to map file, for Sourcemappingurl comment in generated CSS file. -RP,--rootpath=url sets RootPath for URL rewriting in relative imports and URLs Works with or without the relative-urls option. -ru,--relative-urls re-writes relative URLs to the base less file. -sm=on|off Turns on or off strict math, where in strict mode, math. --strict-math=on|off Requires brackets. This option is default to ON and then be removed in the future. -su=on|off allows mixed units, e.g. 1px+1em or 1px*1px which has units--strict-units=on|off that cannot Be represented. --global-var= ' Var=value ' defines a variable that can is referenced by the file. --modify-var= ' Var=value ' modifies a variable already declared in the file. --url-args= ' QUERYSTRING ' Adds params into URL tokens (e.g, cb=42 or ' a=1&b =2 ')--plugin=plugin=options Loads a plugin. You can also omit the--plugin= if the plugin begins less-plugin. e.g. the clean CSS plugin is called Less-plugin-clean-css once installed (NPM install Less-plugin -CLEAN-CSS), use either with--plugin=less-plugin-clean-css or just--clean-css Specify options afterwards e.g.--plugin=less-plugin-clean-css= "advanced" or--clean-css= ' Advanced '-------------------------Deprecated------------------line-numbers=type Outputs filename and line numbers . TYPE can be either ' comments ', which would output the debug info within comments, ' mediaquery ' That would output the information within a fake media query which is Compati ble with the SASS format, and ' all ' which would do both. --verbose Be verbose. -X,--compress compresses output by removing some whitespaces. We recommend you with a dedicated minifer like Less-plugin-clean-css
Compiling less source files using the command line