css-preprocessor-variables
v1.1.0
Published
A plugin for convert css preprocessor file`s variables to json.
Downloads
3
Maintainers
Readme
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' }
})();
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;
}