Skip to content
This repository has been archived by the owner on Sep 11, 2021. It is now read-only.

Svelte extractor for purgecss - Get css selectors from svelte file

License

Notifications You must be signed in to change notification settings

utherpally/purgecss-from-svelte

 
 

Repository files navigation

purgecss-from-svelte

Build Status CircleCi dependencies Status Codacy Badge npm license

Get the selectors of an Svelte3 file.

Install

npm i -D purgecss-from-svelte

Usage

Use with Purgecss - PostCSS

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)];
}

Use alone

import PurgeSvelte from "purgecss-from-svelte";
import fs from "fs";

const htmlContent = fs.readFileSync("index.html");
const selectors = PurgeSvelte.extract(htmlContent);

About

Svelte extractor for purgecss - Get css selectors from svelte file

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%