Helper for building generic names with pattern interpolation, similar to webpack's css-loader. Stable v4.0.0 (latest) uses loader-utils and xxhash64 by default for hashing. Generates scoped class names for CSS Modules, commonly used with postcss-modules-scope. Designed to produce consistent, platform-independent names (fixed in v2.0.1). Breaking changes in v3 and v4 altered hash output — consumers must ensure matching versions with css-loader to avoid class name mismatches.
npm install generic-namesVerified import paths — ran on the pinned version, not inferred.
Shows how to import and use the default export to create a name generator, with pattern and options.
If you rely on stable hashes, pin to v3.x or explicitly configure hashFunction in loader-utils options.
Upgrade css-loader to >=4 to keep class names in sync.
If using without postcss, explicitly set context: process.cwd() to retain old behavior.
Use the same major version of generic-names as the one bundled with your css-loader, or pin both.
Use 'import generate from "generic-names"' or 'const generate = require("generic-names")'.Run 'npm install loader-utils' (or add it to project dependencies).
Ensure exact version locking for generic-names and loader-utils across environments.