css-preprocessor-variables
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

css-preprocessor-variables

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

install

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

usage

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

example

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

(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

options

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

Package Sidebar

Install

npm i css-preprocessor-variables

Weekly Downloads

4

Version

1.1.0

License

MIT

Unpacked Size

13.2 kB

Total Files

14

Last publish

Collaborators

  • fanhaoyuan