Optionalbeautifypretty print css
const result = await transform(css, {beautify: true});
Optionalcomputecompute math functions see supported functions mathFuncs
Optionalcomputecompute shorthand properties
Optionalcomputecompute transform functions see supported functions transformFunctions
Optionalconvertconvert color to the specified color space. 'true' will convert to HEX
Optional Internalcwdcurrent working directory
Optionalexpandexpand nested rules
Optionalindentindent string
Optionalinlineinline css variables
Optionallenientlenient validation. retain nodes that failed validation
Optionalloadurl and file loader
Optionalminifyenable minification
Optionalmodulecss modules options
Optionalnestinggenerate nested rules
Optionalnewnew line string
Optional Internaloutputoutput file. used for url resolution
Optionalparseparse color tokens
Optionalpassdefine minification passes.
Optionalpreservepreserve license comments. license comments are comments that start with /*!
Optionalremoveremove at-rule charset
Optionalremoveremove comments
Optionalremoveremove duplicate declarations from the same rule. if passed as a string array, duplicated declarations are removed, except for those in the array
import {transform} from '@tbela99/css-parser';
const css = `
.table {
width: 100%;
width: calc(100% + 40px);
margin-left: 20px;
margin-left: min(100% , 20px)
}
`;
const result = await transform(css, {
beautify: true,
validation: true,
removeDuplicateDeclarations: ['width']
}
);
console.log(result.code);
Optionalremoveremove empty ast nodes
Optionalremoveremove css prefix
Optionalresolveurl and path resolver
Optionalresolveresolve import
Optionalresolveresolve urls
Optionalsignalabort signal
Example: abort after 10 seconds
const result = await parse(cssString, {
signal: AbortSignal.timeout(10000)
});
Optionalsourcemapinclude sourcemap in the ast. sourcemap info is always generated
Optionalsrcsource file to be used for sourcemap
Optionalvalidationenable css validation
see ValidationLevel
Optionalvisitornode visitor VisitorNodeMap[]
Optionalwithrender the node along with its parents
transform options