npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-sass-extra

v0.3.3

Published

A drop-in replacement for node-sass' Node API that adds support for globs, promises and more.

Downloads

2

Readme

npm Travis (.org) Libraries.io dependency status for GitHub repo GitHub stars GitHub issues GitHub license Open Source Love Commitizen friendly

node-sass-extra

A drop-in replacement for node-sass' Node API that adds support for globs, promises and more.

Why?

:heavy_check_mark: Glob support
:heavy_check_mark: Promise support
:heavy_check_mark: Write css
:heavy_check_mark: Write source maps
:heavy_check_mark: Output to directory
:heavy_check_mark: Dynamically define output destination
:heavy_check_mark: Compile multiple files at once
:heavy_check_mark: Compile multiple files into single output
:heavy_check_mark: Sync and async support
:heavy_check_mark: Non-breaking node-sass API

Install

npm install node-sass-extra -D

Usage

const sass = require('node-sass-extra');

const results = await sass.render({
    file: 'src/**/*.scss',
    [, ...options]
});

// OR

const results = sass.renderSync({
    file: 'src/**/*.scss',
    [, ...options]
});

Options

|Name|Type|Description| |----|----|-----------| |data|string | string[]|String(s) to be compiled.| |file|string | string[]|File(s) to be compiled; can be a file path or a glob pattern.| |output|string | function|The output destination; if provided, files WILL be written to disk. Can be a file path, a directory, or a callback that returns a file path or directory. Must be/return a file path when paired with data.| |outFile|string | function|The output destination; does NOT write files to disk. Can be a file path, a directory, or a callback that returns a file path or directory. Must be/return a file path when paired with data. output will override this value if provided.| |sourceMap|string | function|The source map destination. If paired with output, source maps WILL be written to disk. Either the output or outFile option must be set to use this option. Can be a boolean, a file path, a directory, or a callback that returns a boolean, file path or directory. If a boolean or directory, the file will be named after the output file.| |globOptions|object|The configuration options for the glob pattern.| |...||All other node-sass options.|

Examples

// compile but don't write files
const results = await sass.render({
    file: 'src/**/*.scss',
    outFile: 'css'
});

// write css and source maps
await sass.render({
    file: 'src/**/*.scss',
    output: 'css',
    sourceMap: true
});

// add `.min` suffix to compressed output
await sass.render({
    file: 'src/**/*.scss',
    output: srcFile => srcFile.replace(/.scss$/, '.min.css'),
    outputStyle: 'compressed'
});

// ignore sass partials
await sass.render({
    file: 'src/**/*.scss',
    output: 'css',
    globOptions: {
        ignore: '_*.scss',
        follow: true
    }
});

// combine multiple sources into a single output
await sass.render({
    file: 'src/**/*.scss',
    output: 'main.css'
});

// dynamically determine the css and source map destinations
await sass.render({
    file: 'src/**/*.scss',
    output: srcFile => srcFile.replace(/src\//, 'css/'),
    sourceMap: destFile => destFile.replace(/css\//, 'maps/')
});

API

sass.render(options[, callback])

Asynchronous rendering; returns a promise. Promise resolves with a result object(s) and rejects with an error object. If more than one source is compiled an array of results is returned.

const sass = require('node-sass-extra');

const results = await sass.render({
    file: 'src/**/*.scss'
    [, ...options]
});

sass.renderSync(options)

Synchronous rendering; returns a result object(s). If more than one source is compiled an array of results is returned.

const sass = require('node-sass-extra');

const results = sass.renderSync({
    file: 'src/**/*.scss'
    [, ...options]
});

sass.info

Version information for node-sass-extra, node-sass and libsass.

const sass = require('node-sass-extra');

console.log(sass.info);

// outputs something like:

// node-sass-extra 0.1.0   (Wrapper)       [JavaScript]
// node-sass       2.0.1   (Wrapper)       [JavaScript]
// libsass         3.1.0   (Sass Compiler) [C/C++]