1.0.0 • Published 4 years ago
purgecss-from-js v1.0.0
Purgecss-from-js
Get the selectors of a JS file.
This is an experimental js extractor for purgecss. It uses prepack to partially evaluate the javascript code.
Install
npm i -D purgecss-from-js
Usage
Use with Purgecss
import Purgecss from "purgecss"
import purgeHtml from "purgecss-from-js"
const purgeCss = new Purgecss({
content: ["**/*.html"],
css: ["**/*.css"],
extractors: [
{
extractor: purgeJs,
extensions: ["js"]
}
]
})
const result = purgecss.purge()
Use alone
import purgeHtml from "purgecss-from-js"
import fs from "fs"
const htmlContent = fs.readFileSync("index.js")
const htmlSelectors = purgeHtml.extract(htmlContent)