Minomax 0.1.0 released 🚀

Minomax API Reference

Minomax is a comprehensive tool for optimizing web assets, including images, videos, and web documents. Below are the primary functions available in the Minomax API.

Functions

1.minomax

The minomax function orchestrates the entire workflow, including image set generation, image and video compression, and web document minification.

Parameters

  • imageWorkerParams (ImageWorkerParamsMain): Parameters for image compression.
  • videoWorkerParams (VideoWorkerParamsMain): Parameters for video compression.
  • destinationBasePath (string, optional): The base path where outputs will be saved. Defaults to configurations.destPath.
  • ignorePatterns (string[], optional): Patterns to ignore during file operations.
  • webDocFilesPatterns (string[] | false, optional): Patterns for web documents to process. Defaults to ["**/*.css", "**/*.js", "**/*.html", "**/*.htm"].
  • removeOld (boolean, optional): Flag to remove old outputs. Defaults to true.

Description

  1. Pre-processing: Deletes old outputs and copies web document files to the destination path.
  2. Image Set Generation: Generates image sets and transforms <img> tags to <picture>.
  3. Image Compression: Compresses images.
  4. Video Compression: Compresses videos and generates thumbnails.
  5. Web Document Minification: Minifies HTML, CSS, and JS files.

Example

await minomax(
  { targetFormat: "webp" }, 
  { codecType: "wav1", encodeLevel: 2 },
  "./output",
  ["node_modules/**"],
  ["**/*.html"],
  true
);

2.compressImages

Compresses images based on the specified patterns and format.

Parameters

  • pathPatterns (string[]): Patterns for images to compress.
  • targetFormat (ImageWorkerOutputTypes): Desired output format for images.
  • destinationBasePath (string, optional): The base path where compressed images will be saved. Defaults to configurations.destPath.
  • ignorePatterns (string[], optional): Patterns to ignore during file operations.

Description

Compresses images and saves them to the specified destination path.

Example

await compressImages(
  ["**/*.png", "**/*.jpg"],
  "webp",
  "./compressed-images"
);

3.compressVideos

Compresses videos and generates thumbnails.

Parameters

  • pathPatterns (string[]): Patterns for videos to compress.
  • codecType ("wav1" | "mav1" | "mx265"): Codec type for video compression.
  • encodeLevel (1 | 2 | 3, optional): Encoding level. Defaults to 3.
  • destinationBasePath (string, optional): The base path where compressed videos will be saved. Defaults to configurations.destPath.
  • ignorePatterns (string[], optional): Patterns to ignore during file operations.

Description

Compresses videos and generates thumbnails, saving them to the specified destination path.

Example

await compressVideos(
  ["**/*.mp4"],
  "mav1",
  2,
  "./compressed-videos"
);

4.minifyWebdoc

Minifies web documents such as HTML, CSS, and JS.

Parameters

  • pathPatterns (string[]): Patterns for web documents to minify.
  • destinationBasePath (string, optional): The base path where minified documents will be saved. Defaults to configurations.destPath.
  • fileSearchBasePath (string, optional): Base path to search for files. Defaults to process.cwd().
  • ignorePatterns (string[], optional): Patterns to ignore during file operations.

Description

Minifies web documents and saves them to the specified destination path.

Example

await minifyWebdoc(
  ["**/*.html", "**/*.css"],
  "./minified-docs"
);

5.generateImageSets

Generates image sets for different screen sizes, Convert <img> to <picture> with media queries and link thumbnails for videos.

Parameters

  • pathPatterns (string[]): Patterns for HTML files to generate image sets for.
  • destinationBasePath (string, optional): The base path where image sets will be saved. Defaults to configurations.destPath.
  • ignorePatterns (string[], optional): Patterns to ignore during file operations.

Description

Generates image sets and saves them to the specified destination path.

Example

await generateImageSets(
  ["**/*.html"],
  "./dist"
);




Keywords:
  • Minomax API
  • Web asset optimization
  • Image compression API
  • Video compression
  • Web document minification
  • Image set generation
  • API parameters