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

gulp-sass-monster

v1.2.0

Published

Gulp plugin for node-sass with steroids. The project is a revised version of gulp-sass and updated gulp-sass-extended

Downloads

27

Readme

gulp-sass-monster

npm es2015 license Build Status

:us: English | :ru: Русский язык

Gulp plugin for node-sass with steroids. The project is a revised version gulp-sass and updated gulp-sass-extended, which is no longer supported

Javascript Style Guide

Installation

npm i --save gulp-sass-monster
# or using yarn cli
yarn add gulp-sass-monster

Usage example

const gulp = require('gulp');
const sassMonster = require('gulp-sass-monster');
const options = {};
const isSync = true;

gulp.task('sass', function () {
    return gulp.src('./sass/**/*.scss')
        .pipe(sassMonster(options, isSync).on('error', sassMonster.logError))
        .pipe(gulp.dest('./css'));
});

gulp.task('sass:watch', function () {
    gulp.watch('./sass/**/*.scss', gulp.series('sass')); // gulp#4.x
});

Options

You can use the same parameters as for node-sass.
Two parameters are an exception - file and data, they are setting by the plugin.

Extra options

addVariables

type Object | default undefined

Adds custom variables to the renderer.

This parameter is useful only if you compute some values and want to add their result to sass render. Static properties are easier to set in the files themselves.

A few details about the values for this option:

  • each property will be a Sass variable;
  • If the property is an array, it will be Sass list;
  • If the property is an object, it will be Sass map;

Note. You should not have more than one level of nesting in objects and arrays. Otherwise, you may receive incorrect data.

Example:

const gulp = require('gulp');
const sassMonster = require('gulp-sass-monster');
const sourcemaps = require('gulp-sourcemaps');
const options = {
    addVariables: {
        PRODUCTION: yourProductionValue, // true for example
        someOtherDynamicVar: calculatedValue, // '12px' for example 
        myColorsMap: {
            color1: 'blue',
            color2: 'yellow',
        },
        pointList: [
            '1024px',
            '1280px',
            '1366px'
        ]
    }
};
const isSync = true;

gulp.task('sass', function () {
    return gulp.src('./sass/**/*.scss')
        .pipe(sassMonster(options, isSync).on('error', sassMonster.logError))
        .pipe(gulp.dest('./css'));
});

Before sending to the render, the corresponding code will be added to the body of the files

/* generated */ $PRODUCTION: true;
/* generated */ $someOtherDynamicVar: 12px;
/* generated */ $myColorsMap: (color1: blue, color2: yellow);
/* generated */ $pointList: (1024px, 1280px, 1366px);
/// then your code from file 

If the file contains a @charset (which by specification can only be found at the beginning of the file), a block of variables will be inserted after it.

Impact on sourcemaps. You will notice some inconsistencies in the line numbers in the generated sourcemaps and the original files. The more you add variables, the more this discrepancy, since your content will be shifted due to the addition of a block of variables.

afterRender(result, file)

type function | default undefined

Аргументы

The method is called after a successful render. It is important to know that after this method, there is an internal processing of the data result and compiling sourcemaps (if necessary), if you make changes to the result - this will affect the overall result of the plug-in. Use it carefully.

Example of setting additional watches only on imported files

const gulp = require('gulp');
const sassMonster = require('gulp-sass-monster');
const gulpWatchAndTouch = require('gulp-watch-and-touch');

const sassFileWatcher = gulpWatchAndTouch(gulp);
const options = {
    afterRender (result, file) {
        let filePath = file.path;
        let sources = result.stats.includedFiles;
        let newImports = sassFileWatcher(filePath, filePath, sources);
        if (newImports) {
            console.log(`${file.stem} has new imports`);
        }
    }
};
const isSync = true;

gulp.task('sass', function () {
    return gulp.src('./sass/**/*.scss')
        .pipe(sassMonster(options, isSync).on('error', sassMonster.logError))
        .pipe(gulp.dest('./css'));
});

gulp.task('sass:watch', function () {
    gulp.watch('./sass/**/*.scss', gulp.series('sass')); // gulp#4.x
});

isSync

The second argument is the sync renderer flag. If you do not specify it as a positive value, an asynchronous render will be performed.


Source Maps

The plugin supports gulp-sourcemaps.

const gulp = require('gulp');
const sassMonster = require('gulp-sass-monster');
const sourcemaps = require('gulp-sourcemaps');
const options = {};
const isSync = true;

gulp.task('sass', function () {
    return gulp.src('./sass/**/*.scss')
        .pipe(sourcemaps.init())
        .pipe(sassMonster(options, isSync).on('error', sassMonster.logError))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('./css'));
});

Sass Rendering Errors

gulp-sass-monster is just a wrapper for preparing files and parameters that are passed to the node-sass render and also performs the processing of its results.

If you have questions or problems with how Sass works, you should refer to the corresponding node-sass and libsass projects.

If you have problems with the work of the plugin gulp-sass-monster - then go here gulp-sass-monster/issues.


Project Info