diff --git a/README.md b/README.md index a22140c..21d1574 100755 --- a/README.md +++ b/README.md @@ -11,6 +11,19 @@ [📖 **Release Notes**](./CHANGELOG.md) +## Release Note for purgecss 2 +The extractor is now a function that takes the content as an argument. +```js +class Extractor { + static extract(content) {} +} +``` +changes to +```js +function extractor(content) {} +``` + + ## Features * Remove unneeded CSS with ease diff --git a/lib/module.js b/lib/module.js index da20f35..bcc429a 100644 --- a/lib/module.js +++ b/lib/module.js @@ -32,10 +32,8 @@ export default function nuxtPurgeCss(moduleOptions) { whitelistPatternsChildren: [], extractors: [ { - extractor: class { - static extract(content) { - return content.match(/[A-z0-9-:\\/]+/g) || [] - } + extractor(content) { + return content.match(/[A-z0-9-:\\/]+/g) || [] }, extensions: ['html', 'vue', 'js'] } @@ -95,6 +93,15 @@ export default function nuxtPurgeCss(moduleOptions) { return } + if (config.extractors) { + config.extractors.forEach((e) => { + if (e.extractor && e.extractor.extract) { + logger.warn(`extractors need to be defined as function now, transformed class definition to function`) + e.extractor = e.extractor.extract + } + }) + } + const purgeCssPluginsObject = { '@fullhuman/postcss-purgecss': { content: config.paths,