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

https://github.com/neatsoftware/webpack-minimal-classnames

Generate small css class names with webpack css-loader
https://github.com/neatsoftware/webpack-minimal-classnames

css css-loader minification webpack

Last synced: 23 days ago
JSON representation

Generate small css class names with webpack css-loader

Awesome Lists containing this project

README

          

# Webpack Minimal Classnames

Generate small css class names when using css modules with webpack css-loader.
Recommended to do only doing during production builds as a minification step.
This differs from simply using css-loader's `[hash:base64:n]` by handling any collisions & allowing to configure excluded names.

### Example

Input:

```css
.someLongDescriptiveCssClassName {
color: red;
}
.anotherLongDescriptiveCssClassName {
color: green;
}
```

Output:

```css
.xDK {
color: red;
}
.zyv {
color: green;
}
```

### Usage

```js
const MinimalClassnameGenerator = require('webpack-minimal-classnames')

const generateMinimalClassname = MinimalClassnameGenerator({
length: 3,
excludePatterns: [/ad/i]
})

{
test: /\.css$/,
loaders: [
{
loader: 'css-loader',
options: {
modules: {
getLocalIdent: generateMinimalClassname
}
}
}
]
}
```

### Options

**length** _(number)_ - Length of generated class names
default: 3
_If the max number of names is generated for a given length, it will start generating more at an incremented length_

**excludePatterns** _(RegExp[])_ - Array of regex patterns to exclude generating as a class name