Get the selectors of an Svelte3 file.
npm i -D purgecss-from-svelte
import Purgecss from "purgecss";
import PurgeSvelte from "purgecss-from-svelte";
const options = {
content: ["./src/**/*.svelte"],
extractors: [
{
extractor: content => PurgeSvelte.extract(content),
extensions: ["svelte"]
}
]
};
/* Purgecss */
const purgecss = new Purgecss(options);
const result = purgecss.purge();
/* PostCSS */
{
plugins: [require("@fullhuman/postcss-purgecss")(options)];
}
import PurgeSvelte from "purgecss-from-svelte";
import fs from "fs";
const htmlContent = fs.readFileSync("index.html");
const selectors = PurgeSvelte.extract(htmlContent);