Optional
computecompute math functions see supported functions mathFuncs
Optional
computecompute shorthand properties
Optional
computecompute transform functions see supported functions transformFunctions
Optional
Internal
cwdcurrent working directory
Optional
expandexpand nested rules
Optional
inlineinline css variables
Optional
lenientlenient validation. retain nodes that failed validation
Optional
loadurl and file loader
Optional
minifyenable minification
Optional
nestinggenerate nested rules
Optional
parseparse color tokens
Optional
passdefine minification passes.
Optional
removeremove at-rule charset
Optional
removeremove 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);
Optional
removeremove empty ast nodes
Optional
removeremove css prefix
Optional
resolveurl and path resolver
Optional
resolveresolve import
Optional
resolveresolve urls
Optional
signalabort signal
Example: abort after 10 seconds
const result = await parse(cssString, {
signal: AbortSignal.timeout(10000)
});
Optional
sourcemapinclude sourcemap in the ast. sourcemap info is always generated
Optional
srcsource file to be used for sourcemap
Optional
validationenable css validation
see ValidationLevel
Optional
visitornode visitor VisitorNodeMap[]
parser options