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

@emtecinc/sass-render

v0.1.5

Published

An utility for converting sass files to css, with batch file processing, output template file support, watch mode and other useful attributes

Downloads

2

Readme

sass-render

npm Package

An utility for converting sass files to css, with batch file processing, output template file support, watch mode and other useful attributes

Installation

// with npm
npm install @emtecinc/sass-render

// with yarn
yarn add @emtecinc/sass-render

Usage

sass-render takes in following arguments

  1. -s or --source

    This is a mandatory argument.

    The argument takes in a GLOB which represents a source directory containing sass/scss file that need to be converted into css.

    Ex. Consider there is a directory named components within the directory containing package.json, which has sass files that need to be processed.

    Follow the steps below to process the sass files:

    Install sass-render locally as shown above.

    Add below line to scripts in package.json. You can choose any script name. I have chosen render-sass for this example.

    //Since the below command will be used as a npm script, the quotes need to escaped so using \ before "
    
    "scripts": {
        "render-sass":" sass-render -s \"components/**/scss/*.scss\" "
    }

    OR

    "scripts": {
        "render-sass":" sass-render --source \"components/**/scss/*.scss\" "
    }
  2. -t or --template

    This is an optional argument.

    It is a very useful argument, which can be used to inject the converted sass output into a template, to transform the final output.

    This attribute takes in the path of a template.

    Ex. Assume I have below template stored in a file named my-template.template in the same directory as package.json

    This a sample template.
    
    The output will be substituted here <% content %>
    

    The <% content %> tag defines the placeholder. By default utility will look out for this place holder in the template.

    Add the attribute -t or --template as shown below, to use the template file.

      "scripts": {
          "render-sass":" sass-render -s \"components/**/scss/*.scss\" -t \"my-template.template\" "
      }

    OR

     "scripts": {
          "render-sass":" sass-render --source \"components/**/scss/*.scss\" --useTemplate \"my-template.template\" "
      }

    If you want to use anything other than content, it can be controlled using -l or --delimiter.

    Ex. If I need to change the default content place holder to say raw.

      "scripts": {
          "render-sass":" sass-render -s \"components/**/scss/*.scss\" -t \"my-template.template\" -l \"raw\" "
      }

    OR

     "scripts": {
          "render-sass":" sass-render --source \"components/**/scss/*.scss\" --template \"my-template.template\" --delimiter \"raw\" "
      }

    By default the extension of the output file is .css. If you want to change it, the -e or --extension attribute can be used.

    Ex. If you want the extension to be js, simply set -e or --extension to js as shown below.

      "scripts": {
          "render-sass":" sass-render -s \"components/**/scss/*.scss\" -t \"my-template.template\" -l \"raw\" -e \"js\" "
      }

    OR

     "scripts": {
          "render-sass":" sass-render --source \"components/**/scss/*.scss\" --template \"my-template.template\" --delimiter \"raw\" --extension \"js\" "
      }
  3. -o or --output

    This is an optional argument.

    By default the output files are written to the same folder where the source scss file is.

    We can define the folder where it will be written by passing in the output folder using -o or --output attribute.

    Ex. If we need the files to be written to css directory, pass it as attribute as shown below.

    "scripts": {
        "render-sass":" sass-render -s \"components/**/scss/*.scss\" -o \"css\" "
    }

    OR

    "scripts": {
        "render-sass":" sass-render --source \"components/**/scss/*.scss\" --output \"css\" "
    }
  4. -r or --computeRelativePath

    This is an optional argument.

    We can compute the relative path of output directory with respect to source file path, with help of this attribute.

    Ex. If we need to go one folder up in the file tree with respect to source scss file, we can set this attribute and folder control operator ../ as shown below.

    "scripts": {
        "render-sass":" sass-render -r -s \"components/**/scss/*.scss\" -o \"../css\" "
    }

    OR

    "scripts": {
        "render-sass":" sass-render --computeRelativePath --source \"components/**/scss/*.scss\" --output \"../css\" "
    }
  5. -p or --persistParentDirectory

    This is an optional argument.

    We can persist the parent directory structure of the source scss file being processed.

    Ex. If the source file are in src folder and you want to go one folder up and write the files to ../output/src folder, use the -p or --persistParentDirectory attribute as shown below. Since the source files are in src folder, -p attribute will help preserve it and -r attribute will help to do relative path calculation as shown in previous example.

    "scripts": {
        "render-sass":" sass-render -r -p -s \"components/**/scss/*.scss\" -o \"../output\" "
    }

    OR

    "scripts": {
        "render-sass":" sass-render --computeRelativePath --persistParentDirectory --source \"components/**/scss/*.scss\" --output \"../css\" "
    }
  6. -w or --watch

    This is an optional argument.

    If you want to watch out for source scss file changes, use this attribute.

    "scripts": {
       "render-sass":" sass-render -w -s \"components/**/scss/*.scss\" -o \"css\" "
    }

    OR

    "scripts": {
        "render-sass":" sass-render --watch --source \"components/**/scss/*.scss\" --output \"css\" "
    }

License

This project is licensed under the terms of the GPL3 license.