Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scss-parser

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scss-parser

A library to parse/stringify SCSS

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is scss-parser?

The scss-parser npm package is a tool for parsing SCSS (Sassy CSS) code into an Abstract Syntax Tree (AST). This allows developers to analyze, manipulate, and transform SCSS code programmatically.

What are scss-parser's main functionalities?

Parsing SCSS to AST

This feature allows you to parse SCSS code into an Abstract Syntax Tree (AST). The AST can then be used for further analysis or transformation of the SCSS code.

const scssParser = require('scss-parser');
const input = '$color: #333; .class { color: $color; }';
const ast = scssParser.parse(input);
console.log(JSON.stringify(ast, null, 2));

Traversing the AST

This feature allows you to traverse the AST to find specific nodes, such as variables, mixins, or rules. This can be useful for analyzing or modifying specific parts of the SCSS code.

const scssParser = require('scss-parser');
const createQueryWrapper = require('query-ast');
const input = '$color: #333; .class { color: $color; }';
const ast = scssParser.parse(input);
const $ = createQueryWrapper(ast);
const variables = $.find('variable');
variables.each((node) => {
  console.log(node);
});

Modifying the AST

This feature allows you to modify the AST, which can be useful for transforming SCSS code. For example, you can change variable names, update values, or add new rules.

const scssParser = require('scss-parser');
const createQueryWrapper = require('query-ast');
const input = '$color: #333; .class { color: $color; }';
const ast = scssParser.parse(input);
const $ = createQueryWrapper(ast);
const variables = $.find('variable');
variables.each((node) => {
  node.value.value = '$new-color';
});
console.log(JSON.stringify(ast, null, 2));

Other packages similar to scss-parser

FAQs

Package last updated on 08 Dec 2022

Did you know?

Socket

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.

Install

Related posts

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