Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/teplostanski/vite-plugin-pretty-module-classnames

Adds the filename without the -module suffix to the class names of CSS modules.
https://github.com/teplostanski/vite-plugin-pretty-module-classnames

css css-modules less plugin scss scss-modules vite vite-plugin

Last synced: about 1 month ago
JSON representation

Adds the filename without the -module suffix to the class names of CSS modules.

Lists

README

        


vite-plugin-pretty-module-classnames

[NPM Version](https://npmjs.com/package/vite-plugin-pretty-module-classnames)
[NPM License](https://npmjs.com/package/vite-plugin-pretty-module-classnames)
[NPM Type Definitions](https://npmjs.com/package/vite-plugin-pretty-module-classnames)
[NPM Downloads](https://npmjs.com/package/vite-plugin-pretty-module-classnames)
[GitHub commit activity](https://github.com/teplostanski/vite-plugin-pretty-module-classnames)
[GitHub last commit](https://github.com/teplostanski/vite-plugin-pretty-module-classnames)
[GitHub Issues or Pull Requests](https://github.com/teplostanski/vite-plugin-pretty-module-classnames/issues)
[GitHub Issues or Pull Requests](https://github.com/teplostanski/vite-plugin-pretty-module-classnames/pulls)




Adds the filename without the -module suffix to the class names of CSS modules.


Included in the Awesome Vite.js list Awesome


## Install

[npmjs.com](https://npmjs.com/package/vite-plugin-pretty-module-classnames)

```bash
npm install -D vite-plugin-pretty-module-classnames
```

## Features

- Framework-agnostic
- Support CommonJS and ES Modules
- Support Vite 2.x

## Why Use This?

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!

## Usege

```js
// vite.config.js
import PrettyModuleClassnames from "vite-plugin-pretty-module-classnames";

export default defineConfig({
plugins: [PrettyModuleClassnames()],
});
```

## License [MIT](./LICENSE)