$ show webpack/minimizer-webpack-plugin
minimizer-webpack-plugin is a production-grade webpack 5 plugin that minifies JavaScript, CSS, HTML, JSON, SVG, and image assets through a single configurable interface. It is the consolidated successor to terser-webpack-plugin, css-minimizer-webpack-plugin, and html-minimizer-webpack-plugin. The plugin hooks into webpack's processAssets, chunkHash, and renderEmbeddedSource pipelines to compress bundle output, compose source maps, extract license comments, generate transformed assets such as image format conversions, and optionally parallelize minification with jest-worker. The implementation is a library/plugin architecture, not a standalone service: src/index.js exposes the plugin class and wiring, src/minify.js orchestrates minification and source-map handling, and src/utils.js contains the built-in minimizer adapters for terser, esbuild, swc, cssnano, sharp, svgo, and many other engines.
The LLM identified 3 files worth highlighting for reuse:
Self-contained utility that identifies binary asset types (PNG, JPEG, GIF, WebP, AVIF, HEIC, JPEG XL, SVG, and more) by inspecting leading bytes of a buffer. It includes low-level byte helpers such as startsWith and hasTextIgnoringCase, and requires no external dependencies. This module can be extracted into any Node project needing robust format sniffing from raw buffers.
Exports several standalone, reusable helpers: throttleAll (a concurrency-limited task runner), packageVersion (walks node_modules to resolve a package version without depending on exports maps), readQuery/mergeRequested (parses per-asset URL query overrides), and interpolateSize/replaceExtension (asset filename templating). These utilities are implementation-isolated enough to be lifted into other build tooling projects, and they demonstrate careful handling of edge cases around package resolution, query strings, and worker concurrency.
Custom Jest snapshot serializer that replaces volatile content hashes with stable placeholder tokens, making snapshot tests resilient to unrelated hash differences. This is a reusable testing pattern for any webpack plugin or build-tool test suite that asserts generated asset names, source maps, or bundle output without coupling those assertions to exact hash values.