Skip to content

posthtml/posthtml-postcss-treeshaker

Repository files navigation

posthtml-postcss-treeshaker

A posthtml plugin to treeshake class and id styling in style tag on html page using postcss

NPM Deps Build Standard Code Style Chat

This plugin is used for reducing your file size

Experimental - Work in progress

Before:

<html>
  <body>
    <p class="used">HELLO</p>
    <style>
      .used {
        color: red;
      }
      .unused {
        color: green;
      }
    </style>
  </body>
</html>

After:

<html>
  <body>
    <p class="used">HELLO</p>
    <style>
      .used {
        color: red;
      }
    </style>
  </body>
</html>

Install

npm i posthtml posthtml-postcss-treeshaker

Usage

Describe how people can use this plugin. Include info about build systems if it's necessary.

const fs = require("fs");
const posthtml = require("posthtml");
const posthtmlPlugin = require("posthtml-postcss-treeshaker");

posthtml()
  .use(
    posthtmlPlugin({
      /* options */
    })
  )
  .process(html /*, options */)
  .then(result => fs.writeFileSync("./after.html", result.html));

Contributing

See PostHTML Guidelines and contribution guide.

License MIT

About

posthtml plugin to tree shake css styles using postcss

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published