npm install -D vite-plugin-pretty-module-classnames
- Framework-agnostic
- Tested: without frameworks, React, Vue
- Potentially works with any framework. If you have any problems, write to the Issue
- Support CommonJS and ES Modules
- Support Vite 2.x
As utilizing CSS modules in React, we're accustomed to seeing class names formatted as SomeComponent__classname_hash
. However, with Vite, the naming convention for modular class names appears slightly different, resembling __classname_hash
or SomeComponent-module__classname_hash
the latter occurring if generateScopedName: '[name]__[local]_[hash:base64:5]'
is specified in vite.config.js. This addition of -module
post-component name can be cumbersome to work around.
Fortunately, the vite-plugin-pretty-module-classnames
provides a solution to this issue!
// vite.config.js
import PrettyModuleClassnames from "vite-plugin-pretty-module-classnames";
export default defineConfig({
plugins: [PrettyModuleClassnames()],
});
Before you contribute to the development of the project, read the rules.