@types/clean-css

  • Version 4.2.11
  • Published
  • 25.2 kB
  • 2 dependencies
  • MIT license

Install

npm i @types/clean-css
yarn add @types/clean-css
pnpm add @types/clean-css

Overview

TypeScript definitions for clean-css

Index

Variables

variable CleanCSS

const CleanCSS: CleanCSS.Constructor;
  • Creates a new CleanCSS object which can be used to minify css

Interfaces

interface CompatibilityOptions

interface CompatibilityOptions {}
  • Fine grained configuration for compatibility option

property colors

colors?:
| {
/**
* Controls `rgba()` / `hsla()` color support; defaults to `true`
*/
opacity?: boolean | undefined;
}
| undefined;
  • A hash of compatibility options related to color

property properties

properties?:
| {
/**
* Controls background-clip merging into shorthand; defaults to `true`
*/
backgroundClipMerging?: boolean | undefined;
/**
* Controls background-origin merging into shorthand; defaults to `true`
*/
backgroundOriginMerging?: boolean | undefined;
/**
* Controls background-size merging into shorthand; defaults to `true`
*/
backgroundSizeMerging?: boolean | undefined;
/**
* controls color optimizations; defaults to `true`
*/
colors?: boolean | undefined;
/**
* Controls keeping IE bang hack; defaults to `false`
*/
ieBangHack?: boolean | undefined;
/**
* Controls keeping IE `filter` / `-ms-filter`; defaults to `false`
*/
ieFilters?: boolean | undefined;
/**
* Controls keeping IE prefix hack; defaults to `false`
*/
iePrefixHack?: boolean | undefined;
/**
* Controls keeping IE suffix hack; defaults to `false`
*/
ieSuffixHack?: boolean | undefined;
/**
* Controls property merging based on understandably; defaults to `true`
*/
merging?: boolean | undefined;
/**
* Controls shortening pixel units into `pc`, `pt`, or `in` units; defaults to `false`
*/
shorterLengthUnits?: false | undefined;
/**
* Controls keeping space after closing brace - `url() no-repeat` into `url()no-repeat`; defaults to `true`
*/
spaceAfterClosingBrace?: true | undefined;
/**
* Controls keeping quoting inside `url()`; defaults to `false`
*/
urlQuotes?: boolean | undefined;
/**
* Controls removal of units `0` value; defaults to `true`
*/
zeroUnits?: boolean | undefined;
}
| undefined;
  • A hash of properties that can be set with compatibility

property selectors

selectors?:
| {
/**
* Controls extra space before `nav` element; defaults to `false`
*/
adjacentSpace?: boolean | undefined;
/**
* Controls removal of IE7 selector hacks, e.g. `*+html...`; defaults to `true`
*/
ie7Hack?: boolean | undefined;
/**
* Controls a whitelist of mergeable pseudo classes; defaults to `[':active', ...]`
*/
mergeablePseudoClasses?: readonly string[] | undefined;
/**
* Controls a whitelist of mergeable pseudo elements; defaults to `['::after', ...]`
*/
mergeablePseudoElements: readonly string[];
/**
* Controls maximum number of selectors in a single rule (since 4.1.0); defaults to `8191`
*/
mergeLimit: number;
/**
* Controls merging of rules with multiple pseudo classes / elements (since 4.1.0); defaults to `true`
*/
multiplePseudoMerging: boolean;
}
| undefined;
  • A hash of options related to compatibility of selectors

property units

units?:
| {
/**
* Controls treating `ch` as a supported unit; defaults to `true`
*/
ch?: boolean | undefined;
/**
* Controls treating `in` as a supported unit; defaults to `true`
*/
in?: boolean | undefined;
/**
* Controls treating `pc` as a supported unit; defaults to `true`
*/
pc?: boolean | undefined;
/**
* Controls treating `pt` as a supported unit; defaults to `true`
*/
pt?: boolean | undefined;
/**
* Controls treating `rem` as a supported unit; defaults to `true`
*/
rem?: boolean | undefined;
/**
* Controls treating `vh` as a supported unit; defaults to `true`
*/
vh?: boolean | undefined;
/**
* Controls treating `vm` as a supported unit; defaults to `true`
*/
vm?: boolean | undefined;
/**
* Controls treating `vmax` as a supported unit; defaults to `true`
*/
vmax?: boolean | undefined;
/**
* Controls treating `vmin` as a supported unit; defaults to `true`
*/
vmin?: boolean | undefined;
}
| undefined;
  • A hash of options related to comparability of supported units

interface Constructor

interface Constructor {}
  • Constructor interface for CleanCSS

construct signature

new (options: OptionsPromise): MinifierPromise;

    construct signature

    new (options?: OptionsOutput): MinifierOutput;

      interface FormatOptions

      interface FormatOptions {}
      • Fine grained options for configuring the CSS formatting

      property breaks

      breaks?:
      | {
      /**
      * Controls if a line break comes after an at-rule; e.g. `@charset`; defaults to `false`
      */
      afterAtRule?: boolean | undefined;
      /**
      * Controls if a line break comes after a block begins; e.g. `@media`; defaults to `false`
      */
      afterBlockBegins?: boolean | undefined;
      /**
      * Controls if a line break comes after a block ends, defaults to `false`
      */
      afterBlockEnds?: boolean | undefined;
      /**
      * Controls if a line break comes after a comment; defaults to `false`
      */
      afterComment?: boolean | undefined;
      /**
      * Controls if a line break comes after a property; defaults to `false`
      */
      afterProperty?: boolean | undefined;
      /**
      * Controls if a line break comes after a rule begins; defaults to `false`
      */
      afterRuleBegins?: boolean | undefined;
      /**
      * Controls if a line break comes after a rule ends; defaults to `false`
      */
      afterRuleEnds?: boolean | undefined;
      /**
      * Controls if a line break comes before a block ends; defaults to `false`
      */
      beforeBlockEnds?: boolean | undefined;
      /**
      * Controls if a line break comes between selectors; defaults to `false`
      */
      betweenSelectors?: boolean | undefined;
      }
      | undefined;
      • Controls where to insert breaks

      property breakWith

      breakWith?: string | undefined;
      • Controls the new line character, can be '\r\n' or '\n'(aliased as 'windows' and 'unix' or 'crlf' and 'lf'); defaults to system one, so former on Windows and latter on Unix

      property indentBy

      indentBy?: number | undefined;
      • Controls number of characters to indent with; defaults to 0

      property indentWith

      indentWith?: 'space' | 'tab' | undefined;
      • Controls a character to indent with, can be 'space' or 'tab'; defaults to 'space'

      property semicolonAfterLastProperty

      semicolonAfterLastProperty?: boolean | undefined;
      • Controls removing trailing semicolons in rule; defaults to false - means remove

      property spaces

      spaces?:
      | {
      /**
      * Controls if spaces come around selector relations; e.g. `div > a`; defaults to `false`
      */
      aroundSelectorRelation?: boolean | undefined;
      /**
      * Controls if a space comes before a block begins; e.g. `.block {`; defaults to `false`
      */
      beforeBlockBegins?: boolean | undefined;
      /**
      * Controls if a space comes before a value; e.g. `width: 1rem`; defaults to `false`
      */
      beforeValue?: boolean | undefined;
      }
      | undefined;
      • Controls where to insert spaces

      property wrapAt

      wrapAt?: false | number | undefined;
      • Controls maximum line length; defaults to false

      interface MinifierOutput

      interface MinifierOutput {}
      • Interface exposed when a new CleanCSS object is created

      method minify

      minify: {
      (sources: Sources, callback?: (error: any, output: Output) => void): Output;
      (
      sources: any,
      sourceMap: any,
      callback?: (error: any, output: Output) => void
      ): Output;
      };

        interface MinifierPromise

        interface MinifierPromise {}
        • Interface exposed when a new CleanCSS object is created with returnPromise set to true

        method minify

        minify: (sources: Sources, sourceMap?: RawSourceMap | string) => Promise<Output>;

          interface OptimizationsOptions

          interface OptimizationsOptions {}
          • Fine grained options for configuring optimizations

          property 1

          1?:
          | {
          /**
          * Sets all optimizations at this level unless otherwise specified
          */
          all?: boolean | undefined;
          /**
          * Controls `@charset` moving to the front of a stylesheet; defaults to `true`
          */
          cleanupCharsets?: boolean | undefined;
          /**
          * Controls URL normalization; defaults to `true`
          */
          normalizeUrls?: boolean | undefined;
          /**
          * Controls `background` property optimizations; defaults to `true`
          */
          optimizeBackground?: boolean | undefined;
          /**
          * Controls `border-radius` property optimizations; defaults to `true`
          */
          optimizeBorderRadius?: boolean | undefined;
          /**
          * Controls `filter` property optimizations; defaults to `true`
          */
          optimizeFilter?: boolean | undefined;
          /**
          * Controls `font` property optimizations; defaults to `true`
          */
          optimizeFont?: boolean | undefined;
          /**
          * Controls `font-weight` property optimizations; defaults to `true`
          */
          optimizeFontWeight?: boolean | undefined;
          /**
          * Controls `outline` property optimizations; defaults to `true`
          */
          optimizeOutline?: boolean | undefined;
          /**
          * Controls removing empty rules and nested blocks; defaults to `true`
          */
          removeEmpty?: boolean | undefined;
          /**
          * Controls removing negative paddings; defaults to `true`
          */
          removeNegativePaddings?: boolean | undefined;
          /**
          * Controls removing quotes when unnecessary; defaults to `true`
          */
          removeQuotes?: boolean | undefined;
          /**
          * Controls removing unused whitespace; defaults to `true`
          */
          removeWhitespace?: boolean | undefined;
          /**
          * Contols removing redundant zeros; defaults to `true`
          */
          replaceMultipleZeros?: boolean | undefined;
          /**
          * Controls replacing time units with shorter values; defaults to `true`
          */
          replaceTimeUnits?: boolean | undefined;
          /**
          * Controls replacing zero values with units; defaults to `true`
          */
          replaceZeroUnits?: boolean | undefined;
          /**
          * Rounds pixel values to `N` decimal places; `false` disables rounding; defaults to `false`
          */
          roundingPrecision?: boolean | undefined;
          /**
          * denotes selector sorting method; can be `'natural'` or `'standard'`, `'none'`, or false (the last two
          * since 4.1.0); defaults to `'standard'`
          */
          selectorsSortingMethod?: 'standard' | 'natural' | 'none' | undefined;
          /**
          * denotes a number of /*! ... * / comments preserved; defaults to `all`
          */
          specialComments?: string | undefined;
          /**
          * Controls at-rules (e.g. `@charset`, `@import`) optimizing; defaults to `true`
          */
          tidyAtRules?: boolean | undefined;
          /**
          * Controls block scopes (e.g. `@media`) optimizing; defaults to `true`
          */
          tidyBlockScopes?: boolean | undefined;
          /**
          * Controls selectors optimizing; defaults to `true`
          */
          tidySelectors?: boolean | undefined;
          /**
          * Defines a callback for fine-grained property optimization; defaults to no-op
          */
          transform?:
          | ((
          propertyName: string,
          propertyValue: string,
          selector?: string
          ) => string)
          | undefined;
          }
          | undefined;

            property 2

            2?:
            | {
            /**
            * Sets all optimizations at this level unless otherwise specified
            */
            all?: boolean | undefined;
            /**
            * Controls adjacent rules merging; defaults to true
            */
            mergeAdjacentRules?: boolean | undefined;
            /**
            * Controls merging properties into shorthands; defaults to true
            */
            mergeIntoShorthands?: boolean | undefined;
            /**
            * Controls `@media` merging; defaults to true
            */
            mergeMedia?: boolean | undefined;
            /**
            * Controls non-adjacent rule merging; defaults to true
            */
            mergeNonAdjacentRules?: boolean | undefined;
            /**
            * Controls semantic merging; defaults to false
            */
            mergeSemantically?: boolean | undefined;
            /**
            * Controls property overriding based on understandably; defaults to true
            */
            overrideProperties?: boolean | undefined;
            /**
            * Controls removing empty rules and nested blocks; defaults to `true`
            */
            removeEmpty?: boolean | undefined;
            /**
            * Controls non-adjacent rule reducing; defaults to true
            */
            reduceNonAdjacentRules?: boolean | undefined;
            /**
            * Controls duplicate `@font-face` removing; defaults to true
            */
            removeDuplicateFontRules?: boolean | undefined;
            /**
            * Controls duplicate `@media` removing; defaults to true
            */
            removeDuplicateMediaBlocks?: boolean | undefined;
            /**
            * Controls duplicate rules removing; defaults to true
            */
            removeDuplicateRules?: boolean | undefined;
            /**
            * Controls unused at rule removing; defaults to false (available since 4.1.0)
            */
            removeUnusedAtRules?: boolean | undefined;
            /**
            * Controls rule restructuring; defaults to false
            */
            restructureRules?: boolean | undefined;
            /**
            * Controls which properties won't be optimized, defaults to `[]` which means all will be optimized (since 4.1.0)
            */
            skipProperties?: readonly string[] | undefined;
            }
            | undefined;

              interface Output

              interface Output {}
              • Output returned when calling minify functions

              property errors

              errors: string[];
              • A list of errors raised

              property sourceMap

              sourceMap?: SourceMapGenerator;
              • Output source map if requested with sourceMap option

              property stats

              stats: {
              /**
              * Original content size after import inlining
              */
              originalSize: number;
              /**
              * Optimized content size
              */
              minifiedSize: number;
              /**
              * Time spent on optimizations in milliseconds
              */
              timeSpent: number;
              /**
              * `(originalSize - minifiedSize) / originalSize`, e.g. 0.25 if size is reduced from 100 bytes to 75 bytes
              */
              efficiency: number;
              };
              • Contains statistics on the minify process

              property styles

              styles: string;
              • Optimized output CSS as a string

              property warnings

              warnings: string[];
              • A list of warnings raised

              interface Source

              interface Source {}
              • Hash of input source(s). Passing an array of hashes allows you to explicitly specify the order in which the input files are concatenated. Whereas when you use a single hash the order is determined by the traversal order of object properties

              index signature

              [path: string]: {
              /**
              * The contents of the file, should be css
              */
              styles: string;
              /**
              * The source map of the file, if needed
              */
              sourceMap?: RawSourceMap | string | undefined;
              };
              • Path to file

              Type Aliases

              type FetchCallback

              type FetchCallback = (message: string | number, body: string) => void;
              • Callback type when fetch is used

              type Minifier

              type Minifier = MinifierOutput | MinifierPromise;
              • Union type for both types of minifier functions

              type Options

              type Options = OptionsPromise | OptionsOutput;
              • Discriminant union of both sets of options types. If you initialize without setting returnPromise: true and want to return a promise, you will need to cast to the correct options type so that TypeScript knows what the expected return type will be: (options = options as CleanCSS.OptionsPromise).returnPromise = true

              type OptionsOutput

              type OptionsOutput = OptionsBase & {
              /**
              * If you prefer clean-css to return a Promise object then you need to explicitly ask for it; defaults to `false`
              */
              returnPromise?: false | undefined;
              };
              • Options when returning an output

              type OptionsPromise

              type OptionsPromise = OptionsBase & {
              /**
              * If you prefer clean-css to return a Promise object then you need to explicitly ask for it; defaults to `false`
              */
              returnPromise: true;
              };
              • Options when returning a promise

              type Sources

              type Sources = string | readonly string[] | Source | readonly Source[] | Buffer;
              • Union of all types acceptable as input for the minify function

              Package Files (1)

              Dependencies (2)

              Dev Dependencies (0)

              No dev dependencies.

              Peer Dependencies (0)

              No peer dependencies.

              Badge

              To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

              You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/clean-css.

              • Markdown
                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/clean-css)
              • HTML
                <a href="https://www.jsdocs.io/package/@types/clean-css"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>