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

    Interface ParserOptions

    parser options

    interface ParserOptions {
        computeCalcExpression?: boolean;
        computeShorthand?: boolean;
        computeTransform?: boolean;
        cwd?: string;
        expandNestingRules?: boolean;
        inlineCssVariables?: boolean;
        lenient?: boolean;
        load?: (url: string, currentUrl: string, asStream?: boolean) => LoadResult;
        minify?: boolean;
        nestingRules?: boolean;
        parseColor?: boolean;
        pass?: number;
        removeCharset?: 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[];
    }

    Hierarchy (View Summary)

    Index

    Properties

    computeCalcExpression?: boolean

    compute math functions see supported functions mathFuncs

    computeShorthand?: boolean

    compute shorthand properties

    computeTransform?: boolean

    compute transform functions see supported functions transformFunctions

    cwd?: string

    current working directory

    expandNestingRules?: boolean

    expand nested rules

    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

    parseColor?: boolean

    parse color tokens

    pass?: number

    define minification passes.

    removeCharset?: boolean

    remove at-rule charset

    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[]