kaven-utils - v6.1.2
    Preparing search index...

    Function MinifyCss

    • Recursively minifies CSS files starting from one or more source paths.

      This asynchronous function walks the provided source path(s) (files or directories), finds files with the ".css" extension, and replaces each CSS file's contents with a minified version produced by PostCSS + cssnano. Directory traversal is performed iteratively and files are processed sequentially (no parallel writes).

      Behavior and important details:

      • The options.src value may be a single string path or an array of string paths.
      • If a path points to a file, it is processed only when its extension is ".css".
      • If a path points to a directory, the directory is read and its entries are enqueued for processing. By default, directories named "node_modules" are skipped unless options.includeNodeModules is true.
      • File reads and writes use UTF-8 encoding. Existing CSS files are overwritten in place.
      • Errors obtained while calling stat are logged via options.logger.Warn and the path is skipped; other IO/processing errors are surfaced via thrown exceptions from the underlying async operations unless caught by callers.
      • The function logs successful minification via options.logger.Info and warnings (e.g., ignored node_modules or stat errors) via options.logger.Warn.

      Parameters (IOptions shape summary):

      • options.src: string | string[] — one or more filesystem paths (files or directories)
      • options.includeNodeModules?: boolean — when true, traverses into "node_modules" directories
      • options.logger?: { Info?: (msg: string) => void; Warn?: (msg: string) => void; } — optional logger

      Parameters

      • options: IMinifyCssOptions

        Configuration options for the minification run (see summary above).

      Returns Promise<void>

      A Promise that resolves when all provided paths have been processed.

      • This function performs destructive updates (overwrites CSS files). Ensure you have backups or version control in place if you need to preserve original files.
      • The function is intentionally sequential: if you require parallel processing for performance, perform concurrency control externally.

      6.1.1

      2025-10-23