Skip to content

Commit c742164

Browse files
committed
fix: add readme for css hash length
1 parent bbe543a commit c742164

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,47 @@ import styles from 'Component.module.scss';
13481348
ctx.fillStyle = `${svars.colorBackgroundCanvas}`;
13491349
```
13501350

1351+
### Plugin: One Letter CSS (with hash length check)
1352+
1353+
For efficient gzip/br compression, plugin combine css hash via one symbol name,
1354+
as a classname position at file, with filepath `hash:base64:8`, to have strong sequences
1355+
1356+
**webpack.config.js**
1357+
1358+
```js
1359+
const { OneLetterCss } = require('css-loader/plugins');
1360+
const MyOneLetterCss = new OneLetterCss();
1361+
1362+
const cssHashLen = 8;
1363+
1364+
module.exports = {
1365+
module: {
1366+
rules: [
1367+
{
1368+
test: /\.css$/i,
1369+
loader: 'css-loader',
1370+
options: {
1371+
modules: {
1372+
mode: 'local',
1373+
localIdentName: `[hash:base64:${cssHashLen}]`,
1374+
// for develop
1375+
// localIdentName: `[local]__[hash:base64:${cssHashLen}]`,
1376+
getLocalIdent: MyOneLetterCss.getLocalIdent,
1377+
},
1378+
},
1379+
},
1380+
],
1381+
},
1382+
plugins: [
1383+
...plugins,
1384+
new HashLenSuggest({
1385+
instance: MyOneLetterCss,
1386+
selectedHashLen: cssHashLen,
1387+
}),
1388+
],
1389+
};
1390+
```
1391+
13511392
## Contributing
13521393

13531394
Please take a moment to read our contributing guidelines if you haven't yet done so.

0 commit comments

Comments
 (0)