@tbela99/css-parser
    Preparing search index...

    Interface TransformOptions

    transform options

    interface TransformOptions {
        beautify?: boolean;
        computeCalcExpression?: boolean;
        computeShorthand?: boolean;
        computeTransform?: boolean;
        convertColor?: boolean | ColorType;
        cwd?: string;
        expandNestingRules?: boolean;
        indent?: string;
        inlineCssVariables?: boolean;
        lenient?: boolean;
        load?: (url: string, currentUrl: string, asStream?: boolean) => LoadResult;
        minify?: boolean;
        nestingRules?: boolean;
        newLine?: string;
        output?: string;
        parseColor?: boolean;
        pass?: number;
        preserveLicense?: boolean;
        removeCharset?: boolean;
        removeComments?: boolean;
        removeDuplicateDeclarations?: string | boolean | string[];
        removeEmpty?: boolean;
        removePrefix?: boolean;
        resolve?: (
            url: string,
            currentUrl: string,
            currentWorkingDirectory?: string,
        ) => { absolute: string; relative: string };
        resolveImport?: boolean;
        resolveUrls?: boolean;
        signal?: AbortSignal;
        sourcemap?: boolean | "inline";
        src?: string;
        validation?: boolean | ValidationLevel;
        visitor?: VisitorNodeMap | VisitorNodeMap[];
        withParents?: boolean;
    }

    Hierarchy (View Summary)

    Index

    Properties

    beautify?: boolean

    pretty print css

    const result = await transform(css, {beautify: true});
    
    computeCalcExpression?: boolean

    compute math functions see supported functions mathFuncs

    computeShorthand?: boolean

    compute shorthand properties

    computeTransform?: boolean

    compute transform functions see supported functions transformFunctions

    convertColor?: boolean | ColorType

    convert color to the specified color space. 'true' will convert to HEX

    cwd?: string

    current working directory

    expandNestingRules?: boolean

    expand nested rules

    indent?: string

    indent string

    inlineCssVariables?: boolean

    inline css variables

    lenient?: boolean

    lenient validation. retain nodes that failed validation

    load?: (url: string, currentUrl: string, asStream?: boolean) => LoadResult

    url and file loader

    minify?: boolean

    enable minification

    nestingRules?: boolean

    generate nested rules

    newLine?: string

    new line string

    output?: string

    output file. used for url resolution

    parseColor?: boolean

    parse color tokens

    pass?: number

    define minification passes.

    preserveLicense?: boolean

    preserve license comments. license comments are comments that start with /*!

    removeCharset?: boolean

    remove at-rule charset

    removeComments?: boolean

    remove comments

    removeDuplicateDeclarations?: string | boolean | string[]

    remove 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);
    removeEmpty?: boolean

    remove empty ast nodes

    removePrefix?: boolean

    remove css prefix

    resolve?: (
        url: string,
        currentUrl: string,
        currentWorkingDirectory?: string,
    ) => { absolute: string; relative: string }

    url and path resolver

    resolveImport?: boolean

    resolve import

    resolveUrls?: boolean

    resolve urls

    signal?: AbortSignal

    abort signal

    Example: abort after 10 seconds


    const result = await parse(cssString, {
    signal: AbortSignal.timeout(10000)
    });
    sourcemap?: boolean | "inline"

    include sourcemap in the ast. sourcemap info is always generated

    src?: string

    source file to be used for sourcemap

    validation?: boolean | ValidationLevel

    enable css validation

    see ValidationLevel

    node visitor VisitorNodeMap[]

    withParents?: boolean

    render the node along with its parents