Optionalcomputecompute math functions see supported functions mathFuncs
Optionalcomputecompute shorthand properties
Optionalcomputecompute transform functions see supported functions transformFunctions
Optional Internalcwdcurrent working directory
Optionalexpandexpand nested rules
Optionalinlineinline css variables
Optionallenientlenient validation. retain nodes that failed validation
Optionalloadurl and file loader
Optionalminifyenable minification
Optionalmodulecss modules options
Optionalnestinggenerate nested rules
Optionalparseparse color tokens
Optionalpassdefine minification passes.
Optionalremoveremove at-rule charset
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[]
parser options