posthtml-postcss-treeshaker
v0.3.0
Published
A `posthtml` plugin to treeshake class and id styling in `style` tag on html page using `postcss`
Downloads
14
Maintainers
Readme
posthtml-postcss-treeshaker
A posthtml
plugin to treeshake class and id styling in style
tag on html page using postcss
[![Coverage][cover]][cover-badge]
This plugin is used for reducing your file size
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.