
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
css-var-parser
Advanced tools
npm install css-var-parser
CSS Example :
#element.disabled {
border-left-width: var(--Element_border-left-width--disabled, var(--Radio_border-width--disabled, var(--LC-border-width--disabled, 1px)));
}
JS Example :
import { readFileSync } from "fs";
import css_var_parser from "./src/parser.js";
import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const cssContent = readFileSync(__dirname + "/index.css", "utf-8");
const variables = css_var_parser.parse(cssContent);
console.log(JSON.stringify(variables));
Output:
[
{
selector: "#element.disabled",
properties: [
{
propertyName: "border-left-width",
variables: [
{
name: "--Element_border-left-width--disabled",
fallback: "--Radio_border-width--disabled",
},
{
name: "--Radio_border-width--disabled",
fallback: "--LC-border-width--disabled",
},
{
name: "--LC-border-width--disabled",
fallback: undefined,
},
],
defaultValue: "1px",
}
]
}
]
[NEXT] (changes on master that have not been released yet):
v0.4.1:
FAQs
Extract CSS variable and export them to a JavaScript object
The npm package css-var-parser receives a total of 313 weekly downloads. As such, css-var-parser popularity was classified as not popular.
We found that css-var-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.