# @lesjoursfr/postcss-extract-css-variables

> PostCSS plugin to extract rules with CSS variables

Latest version **3.0.5** (published 2026-07-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @lesjoursfr/postcss-extract-css-variables
pnpm add @lesjoursfr/postcss-extract-css-variables
yarn add @lesjoursfr/postcss-extract-css-variables
bun add @lesjoursfr/postcss-extract-css-variables
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; has provenance; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 3.0.5 |
| Published | 2026-07-01 |
| First published | 2022-01-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 22.x \|\| 24.x \|\| 26.x |
| Dependencies | 0 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Maintainers | e-adrien |
| Keywords | postcss, css, postcss-plugin, postcss-extract-css-variables |

## Links

- npm: https://www.npmjs.com/package/@lesjoursfr/postcss-extract-css-variables
- Repository: https://github.com/lesjoursfr/postcss-extract-css-variables
- Homepage: https://github.com/lesjoursfr/postcss-extract-css-variables#readme
- Issues: https://github.com/lesjoursfr/postcss-extract-css-variables/issues
- npm.io page: https://npm.io/package/@lesjoursfr/postcss-extract-css-variables

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 3.0.5 (latest) — 2026-07-01
- 3.0.4 — 2026-05-05
- 3.0.3 — 2026-03-02
- 3.0.2 — 2026-01-06
- 3.0.1 — 2025-12-01
- 3.0.0 — 2025-10-28
- 2.0.7 — 2025-04-02
- 2.0.6 — 2025-01-02
- 2.0.5 — 2024-12-04
- 2.0.4 — 2024-08-01
- 2.0.3 — 2024-02-01
- 2.0.2 — 2024-01-02
- 2.0.1 — 2023-12-01
- 2.0.0 — 2023-07-03
- 1.0.6 — 2023-02-01
- … 6 more at https://npm.io/package/@lesjoursfr/postcss-extract-css-variables/versions

## README

[![npm version](https://badge.fury.io/js/@lesjoursfr%2Fpostcss-extract-css-variables.svg)](https://badge.fury.io/js/@lesjoursfr%2Fpostcss-extract-css-variables)
[![QC Checks](https://github.com/lesjoursfr/postcss-extract-css-variables/actions/workflows/quality-control.yml/badge.svg)](https://github.com/lesjoursfr/postcss-extract-css-variables/actions/workflows/quality-control.yml)

# postcss-extract-css-variables

[PostCSS] plugin to extract rules with CSS variables.

[postcss]: https://github.com/postcss/postcss

```css
/* Input example */
.lj-color-35 {
	--lj-color-main: #fda92a;
	--lj-color-alpha: rgba(253, 169, 42, 0.75);
	--lj-color-light: #fdde2a;
	--lj-color-mixed: #fdc42a;
}

.selector-1 {
	background-color: var(--lj-color-main);
	content: "";
	display: inline-block;
	height: 5px;
	margin-right: 10px;
	width: 18px;
}
```

```css
/* Output example */
.lj-color-35 .selector-1 {
	background-color: #fda92a;
}
```

## Usage

**Step 1:** Install plugin:

```sh
npm install --save-dev postcss postcss-extract-css-variables
```

**Step 2:** Check you project for existed PostCSS config: `postcss.config.js`
in the project root, `"postcss"` section in `package.json`
or `postcss` in bundle config.

If you do not use PostCSS, add it according to [official docs]
and set this plugin in settings.

**Step 3:** Add the plugin add the end of the plugins list:

```diff
module.exports = {
  plugins: [
    require('autoprefixer'),
+   require('postcss-extract-css-variables')({ output: './output.css' })
  ]
}
```

[official docs]: https://github.com/postcss/postcss#usage

---
_Source: https://npm.io/package/@lesjoursfr/postcss-extract-css-variables · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
