# esbuild-plugin-less

> esbuild plugin for less files

Latest version **1.3.39** (published 2026-06-13) · WTFPL license · 0 weekly downloads

## Install

```sh
npm install esbuild-plugin-less
pnpm add esbuild-plugin-less
yarn add esbuild-plugin-less
bun add esbuild-plugin-less
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.3.39 |
| Published | 2026-06-13 |
| First published | 2021-01-20 |
| Weekly downloads | 0 |
| License | WTFPL |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 11.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 44 |
| Author | Ilya Medvedev |
| Maintainers | imedvedev |
| Keywords | esbuild, plugin, less |

## Links

- npm: https://www.npmjs.com/package/esbuild-plugin-less
- Repository: https://github.com/iam-medvedev/esbuild-plugin-less
- Homepage: https://github.com/iam-medvedev/esbuild-plugin-less#readme
- Issues: https://github.com/iam-medvedev/esbuild-plugin-less/issues
- npm.io page: https://npm.io/package/esbuild-plugin-less

## Dependencies (2)

- [less](https://npm.io/package/less.md) ^4.6.4
- [@types/less](https://npm.io/package/@types/less.md) ^3.0.8

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.3.39 (latest) — 2026-06-13
- 1.3.38 — 2026-04-11
- 1.3.37 — 2026-03-14
- 1.3.36 — 2026-02-06
- 1.3.35 — 2025-12-17
- 1.3.34 — 2025-12-14
- 1.3.33 — 2025-12-05
- 1.3.32 — 2025-11-16
- 1.3.31 — 2025-11-09
- 1.3.30 — 2025-11-02
- 1.3.29 — 2025-11-01
- 1.3.28 — 2025-10-15
- 1.3.27 — 2025-09-19
- 1.3.26 — 2025-08-13
- 1.3.25 — 2025-07-20
- … 57 more at https://npm.io/package/esbuild-plugin-less/versions

## README

# `esbuild-plugin-less`

[![License: WTFPL](https://img.shields.io/badge/License-WTFPL-brightgreen.svg)](http://www.wtfpl.net/about/)
[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-f8bc45.svg)](https://github.com/prettier/prettier)
[![npm version](https://badge.fury.io/js/esbuild-plugin-less.svg)](https://www.npmjs.com/package/esbuild-plugin-less)
[![npm downloads](https://img.shields.io/npm/dt/esbuild-plugin-less.svg)](https://www.npmjs.com/package/esbuild-plugin-less)
[![libraries.io](https://img.shields.io/librariesio/release/npm/esbuild-plugin-less)](https://libraries.io/github/iam-medvedev/esbuild-plugin-less)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fiam-medvedev%2Fesbuild-plugin-less.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fiam-medvedev%2Fesbuild-plugin-less?ref=badge_shield)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

[esbuild](https://github.com/evanw/esbuild) plugin for [LESS](https://lesscss.org/) files.

Supports all LESS features, including [imports](https://lesscss.org/#importing), [variables](https://lesscss.org/#variables), [mixins](https://lesscss.org/#mixins), and more.

## Features

- 💫 Support for all LESS.js features and options
- 🎨 CSS Modules support with `.module.less` files
- 🔄 Watch mode support with automatic rebuilds
- 🎯 Custom file filtering options
- 📝 Written in TypeScript

## Installation

```sh
# Using bun
$ bun add -D esbuild-plugin-less

# Using yarn
$ yarn add -D esbuild-plugin-less

# Using pnpm
$ pnpm add -D esbuild-plugin-less

# Using npm
$ npm install --save-dev esbuild-plugin-less
```

## Basic Usage

```ts
import { build } from 'esbuild';
import { lessLoader } from 'esbuild-plugin-less';

build({
  entryPoints: ['src/index.ts'],
  bundle: true,
  outdir: 'dist',
  plugins: [lessLoader()], // That's it!
  loader: {
    '.ts': 'ts',
  },
});
```

## Advanced Configuration

### With LESS Options

```ts
import { build } from 'esbuild';
import { lessLoader } from 'esbuild-plugin-less';

build({
  entryPoints: ['src/index.ts'],
  bundle: true,
  outdir: 'dist',
  plugins: [
    lessLoader({
      // LESS.js options
      math: 'always',
      globalVars: {
        primaryColor: '#ff0000',
      },
      paths: ['./src/styles'],
      javascriptEnabled: true,
    }),
  ],
});
```

### With Loader Options

```ts
import { build } from 'esbuild';
import { lessLoader } from 'esbuild-plugin-less';

build({
  entryPoints: ['src/index.ts'],
  bundle: true,
  outdir: 'dist',
  plugins: [
    lessLoader(
      {}, // LESS options (empty in this example)
      {
        // Loader options
        filter: /\._?less$/, // Custom file filter
        inline: false, // Control if LESS files should be inlined as strings
      },
    ),
  ],
});
```

## CSS Modules Support

The plugin automatically handles `.module.less` files as CSS Modules. This enables local scoping of styles and generates unique class names.

```less
// styles.module.less
.button {
  color: blue;
}
```

```ts
// Component.ts
import styles from './styles.module.less';
element.className = styles.button; // Will use the generated unique class name
```

## Configuration Options

### LESS Options

The plugin accepts all valid options from LESS.js. Here are some commonly used options:

For a complete list of LESS options, see the [LESS documentation](http://lesscss.org/usage/#less-options).

### Loader Options

| Option   | Type      | Default     | Description                                |
| -------- | --------- | ----------- | ------------------------------------------ |
| `filter` | `RegExp`  | `/\.less$/` | Custom filter for processing files         |
| `inline` | `boolean` | `false`     | Import LESS files as strings in TypeScript |

## License

`esbuild-plugin-less` is [WTFPL licensed](./LICENSE).

[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fiam-medvedev%2Fesbuild-plugin-less.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fiam-medvedev%2Fesbuild-plugin-less?ref=badge_large)

---
_Source: https://npm.io/package/esbuild-plugin-less · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
