New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rehype-remove-unused-css

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rehype-remove-unused-css - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

27

index.js

@@ -26,3 +26,6 @@ /**

const toHtml = require("hast-util-to-html")
const { selectAll } = require("unist-util-select")
const { selectAll } = require("hast-util-select")
const toString = require("hast-util-to-string")
const fromString = require("hast-util-from-string")
const { promisify } = require("util")

@@ -32,19 +35,9 @@ module.exports = function purify(options) {

const html = toHtml(tree)
const nodes = selectAll("[tagName=style]", tree)
await Promise.all(nodes.map((node)=>new Promise((resolve, reject)=>{
const raw = node.children.map(c=>c.value).join()
uncss(html, {...options, raw}, (err, value)=>{
if(err) reject(err)
node.children = [{
value,
type: "text",
position: node.children.every(c=>c.position) ? {
start: node.children[0].position.start,
end: node.children[node.children.length - 1].position.end
} : undefined
}]
resolve()
})
})))
const nodes = selectAll("style", tree)
await Promise.all(nodes.map(async (node)=>{
const raw = toString(node)
const css = await promisify(uncss)(html, {...options, raw})
fromString(node, css)
}))
}
}
{
"name": "rehype-remove-unused-css",
"version": "0.1.2",
"version": "0.1.3",
"description": "Rehype plugin to remove unused stylesheet with uncss",

@@ -23,5 +23,7 @@ "main": "index.js",

"dependencies": {
"hast-util-from-string": "^1.0.3",
"hast-util-select": "^4.0.0",
"hast-util-to-html": "^7.1.1",
"uncss": "^0.17.3",
"unist-util-select": "^3.0.1"
"hast-util-to-string": "^1.0.3",
"uncss": "^0.17.3"
},

@@ -28,0 +30,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc