# css-preprocessor-variables

> A plugin for convert css preprocessor file`s variables to json.

Latest version **1.1.0** (published 2021-09-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install css-preprocessor-variables
pnpm add css-preprocessor-variables
yarn add css-preprocessor-variables
bun add css-preprocessor-variables
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-09-05 |
| First published | 2021-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 12.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | fansy |
| Maintainers | fanhaoyuan |
| Keywords | less, scss, sass, vars, variables, json, css, preprocessor |

## Links

- npm: https://www.npmjs.com/package/css-preprocessor-variables
- Repository: https://github.com/fanhaoyuan/css-preprocessor-variables
- Homepage: https://github.com/fanhaoyuan/css-preprocessor-variables#readme
- Issues: https://github.com/fanhaoyuan/css-preprocessor-variables/issues
- npm.io page: https://npm.io/package/css-preprocessor-variables

## Dependencies (6)

- [postcss](https://npm.io/package/postcss.md) ^8.3.6
- [postcss-less](https://npm.io/package/postcss-less.md) ^5.0.0
- [postcss-scss](https://npm.io/package/postcss-scss.md) ^4.0.0
- [lodash.camelcase](https://npm.io/package/lodash.camelcase.md) ^4.3.0
- [lodash.kebabcase](https://npm.io/package/lodash.kebabcase.md) ^4.1.1
- [lodash.escaperegexp](https://npm.io/package/lodash.escaperegexp.md) ^4.1.2

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.0 (latest) — 2021-09-05
- 1.0.0 — 2021-09-02

## README

# css-preprocessor-variables

A plugin for convert css preprocessor`s variables to json.

## install

```bash
>$ npm install css-preprocessor-variables
#or
>$ yarn add css-preprocessor-variables
```

## usage

```ts
const getVars: (content: string, options: UserOptions) => Promise<Output>;
```

### example

```ts
const getVars = require('css-preprocessor-variables');

getVars('@primary-color: #ffffff;\n @color: #000000', { type: 'less' }).then(({ variable }) => {
    console.log(variables); // { '@primary-color': '#ffffff', 'color': '#000000' }
});
```

or use it with promise

```ts
(async function () {
    const getVars = require('css-preprocessor-variables');

    const { variables } = await getVars('@primary-color: #ffffff;\n @color: #000000', { type: 'less' });

    console.log(variables); // { '@primary-color': '#ffffff', 'color': '#000000' }
})();
```

[More examples in here](./__tests__)

## options

```ts
export interface Options {
    /**
     * Type of parser
     */
    type: 'less';

    /**
     * Format key of variables
     *
     * @default 'default'
     */
    format: 'camelCase' | 'kebabCase' | 'default';

    /**
     * Whether to remove the prefix
     *
     * @default false
     *
     * If true, strip prefix '@' or '$'
     */
    strip: boolean;

    /**
     * transform variables in current result
     *
     * @default true
     */
    transform: boolean;
}
```

## license

[MIT](./LICENSE)

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