# baldwin/magento2-module-less-js-compiler

> Allows Magento 2 to compile less files using the less nodejs compiler

`composer require baldwin/magento2-module-less-js-compiler`

Canonical URL: https://packagento.com/baldwin/magento2-module-less-js-compiler

## At a glance

- **Vendor**: baldwin (https://packagento.com/baldwin.md)
- **Latest version**: v1.7.2 — released 2026-04-14
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/baldwin/magento2-module-less-js-compiler and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require baldwin/magento2-module-less-js-compiler:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Allows Magento 2 to compile less files using the less nodejs compiler

## README

### Description

This module was built out of frustration about the slow deployments of static assets to a production environment while running `bin/magento setup:static-content:deploy`. In particular this module tries to tackle the slowness which comes with compiling less files using the [less.php](https://github.com/oyejorge/less.php) library, which Magento 2 uses by default.  
This module provides a solution by using the [original less.js compiler](https://github.com/less/less.js) which was written in javascript and is executed through node.js  
We have [benchmarked](#benchmarks) the difference between the less.php and less.js compilers, and the less.js compiler is somewhere between 1.5 and 3 times as fast as the less.php compiler, although it depends on your PHP version. If you run PHP 5.x the performance increase will be much higher, PHP 7.x is actually quite fast by itself, but the nodejs version still beats it.

**Update**: Since Magento 2.3.0, it seems like the performance differences between less.php and less.js are not very big anymore. I have the suspicion this might have something to do with newer [releases of the less.php](https://github.com/oyejorge/less.php/releases) library. Which got released somewhere around the period when Magento 2.2.3 & 2.1.12 were released. So it's possible that the performance difference for Magento 2.2.x and 2.1.x might also be less significant then how it's displayed [below](#benchmarks) if you upgrade the less.php library to the latest version (v1.7.0.14 at the time of writing).  
This is a bit of speculation, since unfortunately I didn't keep track of the version of the less.php library which I've used in the benchmarks, so I'm not sure about this statement.

Since Magento 2.4.0 (or newer PHP versions?), the performance differences seems to have changed in favor of less.php.  But you might still want to use this module so that the outputted css is the same between your local development environment and a production environment.

### Requirements

You'll need at least Magento 2.0.7. We didn't bother with testing this module on older versions.  
If you want to use this module, you'll need to be able to install [node.js](https://nodejs.org/) and [npm](https://www.npmjs.com/) on the machine(s) on which you will build your static assets.  
You'll also need to make sure that the `node` binary is available in the `$PATH` environment variable of the user which will build the static assets.  
You'll also need [composer](https://getcomposer.org/) to add this module to your Magento 2 shop.

### Installation

First, we recommend you to install the less compiler itself, and save it into your `package.json` file as a production dependency:

```sh
npm install --save less@3.13.1
```

> Watch out: from Magento 2.1 onwards, the `package.json` file is being renamed to `package.json.sample` to enable you to have your own nodejs dependencies without Magento overwriting this every time with its own version each time you update Magento. So if you use Magento >= 2.1 make sure you copy the `package.json.sample` file to `package.json` before running the above command if you want to work with Magento's `grunt` setup.

Then run a shrinkwrap, so the version of less (and its dependencies) are fixed, this will produce a file `npm-shrinkwrap.json` with the exact versions of all your nodejs production dependencies and their own dependencies, so you can be sure it will use those exact versions when you install this on another machine.

```sh
npm shrinkwrap
```

And make sure you add these two files to your version control system.

> For an analogy with composer, you can compare the `package.json` file with `composer.json`, and `npm-shrinkwrap.json` with `composer.lock`

Now install this module

```sh
composer require baldwin/magento2-module-less-js-compiler
```

And enable it in Magento

```sh
bin/magento module:enable Baldwin_LessJsCompiler
bin/magento setup:upgrade
```

As the last step, in your deploy scripts, make sure you call `npm install --production`. You should execute this somewhere between `composer install` and `bin/magento setup:static-content:deploy`

### Configuration

You have the opportunity to configure the arguments we send to the `lessc` and `node` commands.
The defaults are:

- `lessc --no-color`
- `node --no-deprecation`

If you want to override the default arguments, you can do this by modifying your `app/etc/config.php` or `app/etc/env.php` file and adding something like this:

```php
    'system' => [
        'default' => [
            'dev' => [
                'less_js_compiler' => [
                    'less_arguments' => '--no-color --ie-compat',
                    'node_arguments' => '--no-deprecation --no-warnings',
                ]
            ]
        ]
    ]
```

You can also enable throwing an exception when the less compilation runs into warnings/errors, by default this is disabled and you should find the problems logged in your `var/log/system.log` file.
But if you want to enable throwing an exception during the compilation process, you can by configuring this in your `app/etc/config.php` or `app/etc/env.php` file:

```php
    'system' => [
        'default' => [
            'dev' => [
                'less_js_compiler' => [
                    'throw_on_error' => true,
                ]
            ]
        ]
    ]
```

### Investigating less compilation errors

When your `.less` files have a syntax error or contain something which doesn't allow it to compile properly, please have a look at the `var/log/system.log` file, it will contain some output about what caused the problem.

### Remarks

_(README truncated for .md surface. Full README on https://packagento.com/baldwin/magento2-module-less-js-compiler.)_

## Recent Versions

| Version | Released |
|---|---|
| v1.7.2 | 2026-04-14 |
| v1.7.1 | 2025-04-09 |
| v1.7.0 | 2024-07-17 |
| v1.6.0 | 2024-06-17 |
| v1.5.2 | 2024-03-22 |
| v1.5.1 | 2023-03-01 |
| v1.5.0 | 2022-01-30 |
| v1.4.0 | 2020-08-16 |
| v1.3.0 | 2019-08-30 |
| v1.2.1 | 2019-04-26 |

Showing 10 of 15 versions. Full release history on https://packagento.com/baldwin/magento2-module-less-js-compiler.

## Dependencies

### Require

| Package | Constraint |
|---|---|
| magento/framework | ^100.0.9 \|\| ^101.0.0 \|\| ^102.0.0 \|\| ^103.0.0 |
| magento/module-developer | ^100.0.5 |
| php | ~5.5.0 \|\| ~5.6.0 \|\| ~7.0.0 \|\| ~7.1.0 \|\| ~7.2.0 \|\| ~7.3.0 \|\| ~7.4.0 \|\| ~8.1.0 \|\| ~8.2.0 \|\| ~8.3.0 \|\| ~8.4.0 \|\| ~8.5.0 |
| symfony/process | ^2.8 \|\| ^4.1 \|\| ^5.0 \|\| ^6.0 \|\| ^7.0 |

### Require (dev)

| Package | Constraint |
|---|---|
| bamarni/composer-bin-plugin | ^1.8 |
| ergebnis/composer-normalize | ^2.20 |

## Quality

Latest release (v1.7.2) passes the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | Pass | Pass |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Warning | 8 | 8 warnings (ruleset: Magento2) |
| PHPMD | Pass | 0 |  |
| Cpd | Pass | 0 |  |
| Composer validate | Pass | 0 |  |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | Pass | Pass |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["baldwin/magento2-module-less-js-compiler"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

baldwin is a Magento 2 vendor on Packagento. See https://packagento.com/baldwin.md for their full catalogue.

