Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Html extractor for purgecss - Get css selectors from html

License

Notifications You must be signed in to change notification settings

FullHuman/purgecss-from-html

Repository files navigation

Purgecss-from-html

Build Status CircleCi dependencies Status devDependencies Status Codacy Badge npm license

Get the selectors of an html file.

Install

npm i -D purgecss-from-html

Usage

Use with Purgecss

import Purgecss from "purgecss"
import purgeHtml from "purgecss-from-html"
const purgeCss = new Purgecss({
    content: ["**/*.html"],
    css: ["**/*.css"],
    extractors: [
        {
            extractor: purgeHtml,
            extensions: ["html"]
        }
    ]
})
const result = purgecss.purge()

Use alone

import purgeHtml from "purgecss-from-html"
import fs from "fs"

const htmlContent = fs.readFileSync("index.html")
const htmlSelectors = purgeHtml.extract(htmlContent)