npm.io
1.1.0 • Published 5 years ago

css-preprocessor-variables

Licence
MIT
Version
1.1.0
Deps
6
Size
13 kB
Vulns
0
Weekly
0
Stars
2

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 '

license

MIT

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

license

MIT

Keywords