Skip to content

Squarespace/less-compiler

Repository files navigation

Squarespace LESS Compiler

A Java implementation of the LESS CSS preprocessor language.

Build Status Coverage Status

Current Less.js compatibility level: 1.3.3

License: Apache 2.0 (summary)

Copyright (c) 2021 Squarespace, Inc.

Project Goals

  • Migrate away from use of Node.js + Less.js for server-side conversion of LESS to CSS.
  • Maintain compatibility with Less.js, tracking version 1.3.3 (Squarespace's supported version at the time of development).
  • Improve performance, reduce memory usage where possible.
  • Design must support additional features needed for server-side compilation.
  • Design parsing package to closely track the Less.js parser structure, to simplify verifying correctness.

Features

  • Performance improvement of 2-5x over Less.js when used in server context
  • Improved error messages with full stack traces
  • Execution trace mode
  • Modular parser that supports fine-grained unit testing of syntax fragments
  • High test coverage.

Differences

  • JavaScript evaluation support is missing. It may return if / when we can guarantee speed and safety of JS evaluation in the JVM (Java 8's Nashorn may provide this).
  • Final CSS structure is generated by feeding blocks and rules to a simple model that ensures they are emitted at the correct scope in the output document.
  • Color keywords can participate in math operations.
  • See more complete list of differences

Usage

git clone [email protected]:Squarespace/squarespace-less.git
cd squarespace-less
gradle makeCli
./lessc -h