Skip to content

Command Line Options

Mária Jurčovičová edited this page Feb 18, 2016 · 17 revisions

Less4j can run as a standalone program. Latest complete jar with all dependencies is stored in less4j dropbox account. Command line version can run in two modes:

  • single input file mode,
  • multiple input files mode.

Less4j uses single file mode by default.

Source Map

Both modes are able to generate source map files. Source map links compiled css file to its source less files. If it is available, browser debug tools show original less files instead of css version. They are currently supported only by Chrome and nightly builds of Firefox. You can read more about them on html5 rocks or tutplus sites.

Compression

Less4j supports simple css compression. It removes all comments, indentation, new lines and other unnecessary whitespaces. It does not utilizes all possible css compression tricks, so we recommend to use dedicated css compression if the output size matters a lot.

Single file mode

Less4j expects one or two arguments. First argument contains path to input less file. Second argument is optional and contains path to css file to be generated. If it is missing, less4j will print the result into standard output.

Source map can be generated only if both arguments are supplied.

Multiple files mode

Must be turned on by '-m' or '--multiMode' parameter. Less4j assumes that all input files are less files. All are going to be compiled into css files. Each input file will generate css file with the same name and suffix '.css' and source map file with suffix '.css.map'.

Usage: less4j [options] [list of files]

Options

  • -v, --version Print version. Default: false
  • -h, --help: Print help screen. Default: false
  • -sm, --sourceMap: Turn on source map generation. Default: false
  • -x, --compress: Turn on css output compression. Default: false
  • -iec, --ieCompatibility: Turns off and on ie-compatible limitations. Currently used only inside data-uri function. If it is on, data-uri wont encode images too large for ie8. Turning it off is equivalent to calling less.js with --no-ie-compat option. Default: true
  • -m, --multiMode: Turn on multi less files mode. Default: false
  • -o, --outputDir: Specify the output directory. If not present, Less4j will place output files into current directory. This option is available only in multiple files mode.
  • -pi, --printIncorrect: Print result of syntactically incorrect input file. If not present, syntactically incorrect input files produce no result. If present, less4j prints whatever came out of the compilation as a compilation result - most likely an invalid CSS. Default: false

Examples

  • Compile 'test.less' file and print the result into standard output: java -jar less4j.jar test.less
  • Compile 'test.less' file and print the result into 'test.css' file: java -jar less4j.jar test.less test.css
  • Compile 'test.less' file and print the result into 'test.css' file and generate 'test.css.map' source map file: java -jar less4j.jar -sm test.less test.css
  • Compile 't1.less', 't2.less' and 't3.less' files into 't1.css', 't2.css' and 't3.css': java -jar less4j.jar -m t1.less t2.less t3.less
  • Compile 't1.less', 't2.less', 't3.less' files into 't1.css', 't2.css', 't3.css'. Place the result into '..\css' directory: java -jar less4j.jar -m -o ..\css\ t1.less t2.less t3.less