CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-node-sass

Node.js wrapper around libsass for compiling Sass and SCSS files to CSS

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

node-sass

node-sass is a Node.js wrapper around libsass, the C/C++ port of the popular Sass CSS preprocessor. It provides both programmatic APIs and command-line tools for compiling Sass and SCSS files into CSS, with support for source maps, custom functions, and various output styles.

Package Information

  • Package Name: node-sass
  • Package Type: npm
  • Language: JavaScript (Node.js native module with C++ bindings)
  • Installation: npm install node-sass

Core Imports

const sass = require("node-sass");

For ES modules:

import sass from "node-sass";

Basic Usage

const sass = require("node-sass");

// Compile from file
sass.render({
  file: "input.scss",
  outFile: "output.css",
}, (error, result) => {
  if (error) {
    console.error(error);
  } else {
    console.log(result.css.toString());
  }
});

// Compile from string
sass.render({
  data: "$primary-color: #333; body { color: $primary-color; }",
}, (error, result) => {
  if (error) {
    console.error(error);
  } else {
    console.log(result.css.toString());
  }
});

// Synchronous compilation
try {
  const result = sass.renderSync({
    file: "input.scss"
  });
  console.log(result.css.toString());
} catch (error) {
  console.error(error);
}

Architecture

node-sass is structured around several key components:

  • Core Render Engine: Asynchronous (render) and synchronous (renderSync) compilation functions
  • Sass Type System: Complete type constructors for creating and manipulating Sass values in custom functions
  • CLI Interface: Command-line tool with extensive options for build processes and file watching
  • Binary Management: Platform-specific binary handling with automatic downloads and caching
  • File Watching: Development workflow support with automatic recompilation on file changes

Capabilities

Core Compilation

Primary Sass/SCSS compilation functionality for converting stylesheets to CSS with full configuration options.

function render(options, callback);
function renderSync(options);

Core Compilation

Sass Type System

Complete type system for creating and manipulating Sass values in custom functions, including colors, numbers, strings, lists, and maps.

const types = {
  Boolean: function(value),
  Color: function(r, g, b, a),
  Error: function(message),
  List: function(length, separator),
  Map: function(length),
  Null: function(),
  Number: function(value, unit),
  String: function(value)
};

Sass Type System

Command Line Interface

Comprehensive CLI tool for build processes, file watching, and batch compilation with extensive configuration options.

node-sass [options] <input> [output]
node-sass --watch <input> --output <output>

Command Line Interface

Environment Management

Utilities for managing platform-specific binaries, environment detection, and installation processes.

// Exposed through extensions module (internal)
function getBinaryPath();
function isSupportedEnvironment();
function getVersionInfo(binding);

Environment Management

Constants

const TRUE = sass.TRUE;     // Sass Boolean TRUE singleton
const FALSE = sass.FALSE;   // Sass Boolean FALSE singleton  
const NULL = sass.NULL;     // Sass Null singleton
const info = sass.info;     // Version information string

These constants provide direct access to commonly used Sass singleton values:

  • sass.TRUE - Singleton instance representing Sass boolean true (same as sass.types.Boolean.TRUE)
  • sass.FALSE - Singleton instance representing Sass boolean false (same as sass.types.Boolean.FALSE)
  • sass.NULL - Singleton instance representing Sass null (same as sass.types.Null.NULL)
  • sass.info - String containing version information for node-sass and libsass

Install with Tessl CLI

npx tessl i tessl/npm-node-sass
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/node-sass@9.0.x
Publish Source
CLI
Badge
tessl/npm-node-sass badge