Skip to content

Commit 497812c

Browse files
committed
Update readme to include CSS modules support
1 parent 6688188 commit 497812c

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

README.md

+36
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,42 @@ This plugin, unlike the original PurifyCSS plugin, provides special features, su
8181

8282
> The plugin does **not** emit sourcemaps even if you enable `sourceMap` option on loaders!
8383
84+
<h2 align="center">Usage with CSS Modules</h2>
85+
86+
PurifyCSS doesn't support classes that have been namespaced with CSS Modules. However, by adding a static string to `css-loader`'s `localIdentName`, you can effectively whitelist these namespaced classes.
87+
88+
In this example, `PURIFY` will be our whitelisted string. **Note:** Make sure this string doesn't occur in any of your other CSS class names. Keep in mind that whatever you choose will end up in your application at runtime - try to keep it short!
89+
90+
```javascript
91+
module.exports = {
92+
module: {
93+
rules: [
94+
{
95+
test: /\.css$/,
96+
loader: ExtractTextPlugin.extract({
97+
fallback: 'style-loader',
98+
use: [{
99+
loader: 'css-loader',
100+
query: {
101+
localIdentName: 'PURIFY_[hash:base64:5]',
102+
modules: true
103+
}
104+
}]
105+
})
106+
}
107+
]
108+
},
109+
plugins: [
110+
...,
111+
new PurifyCSSPlugin({
112+
purifyOptions: {
113+
whitelist: ['*PURIFY*']
114+
}
115+
})
116+
]
117+
};
118+
```
119+
84120
<h2 align="center">Maintainers</h2>
85121

86122
<table>

0 commit comments

Comments
 (0)