Skip to content

Commit 7ad9c8e

Browse files
miyanokomiyaTheAlexLichter
authored andcommitted
chore: add how to customize extractors (#53)
1 parent 2252ea5 commit 7ad9c8e

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,39 @@ export default {
171171
}
172172
```
173173

174+
### Use custom extractors
175+
Only one extractor can be applied to each file extention.
176+
If you want to apply a custom extractor to the extensions that the default extractor already covers, you have to override the default extractor. This is only possible with the functional notation.
177+
178+
```js
179+
//nuxt.config.js
180+
export default {
181+
modules: [
182+
'nuxt-purgecss',
183+
],
184+
185+
purgeCSS: {
186+
extractors: () => [
187+
{
188+
extractor: class {
189+
static extract(content) {
190+
return content.match(/[A-z0-9-:\\/]+/g)
191+
}
192+
},
193+
extensions: ['html', 'vue', 'js']
194+
},
195+
{
196+
extractor: class {
197+
static extract(content) {
198+
return content.match(/[A-z0-9-\\/]+/g)
199+
}
200+
},
201+
extensions: ['vue'] // This will not work, because the above extractor is applied to 'vue' already.
202+
}
203+
]
204+
}
205+
}
206+
```
174207

175208
## Development
176209

0 commit comments

Comments
 (0)