Webpack plugin that minifies CSS module class names to short alphanumeric tokens (e.g., .header -> .a) to reduce HTML and CSS size by up to 20%, improving FCP. Stable v0.1.8, requires css-loader >=4.0.0. Supports caching between builds, custom prefixes, and reserved names. The minification logic is derived from next-classnames-minifier. Ships TypeScript types. Alternative to css-minimizer-webpack-plugin for CSS modules specifically.
npm install rs-classnames-minifierNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes ClassnamesMinifier with prefix and cache, then uses getLocalIdent in css-loader for minified classnames.
Ensure your CSS files use CSS modules syntax (e.g., .module.css extension) and are processed by css-loader with modules option enabled.
Set both distDir and cacheDir in constructor options to enable persistent caching across builds.
Avoid relying on specific minified names being permanent; clear cache if upgrading.
Add the prefix (e.g., '_') to reservedNames array when instantiating ClassnamesMinifier.
Remove preLoader/postLoader from webpack config and only use getLocalIdent in css-loader options. See docs for migration.
If you have cached class names, clear cache and rebuild to avoid mismatches.
Run 'npm install classnames-minifier' and ensure package.json contains it.
Use 'const { ClassnamesMinifier } = require('classnames-minifier')' or 'import { ClassnamesMinifier } from 'classnames-minifier''.Set css-loader options.modules.getLocalIdent to cm.getLocalIdent (cm is ClassnamesMinifier instance).
Add cacheDir and distDir options to ClassnamesMinifier constructor.