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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@darius2652/sass-middleware

v1.0.4

Published

An express middleware to automatically convert requested SASS files into CSS routes on the fly, with production caching

Downloads

136

Readme

SASS conversion made easy

SASS Middleware is a simple, automated solution to working with SASS files with express.

Features

  • Easily convert SASS or SCSS to CSS
  • Re-calculates the CSS results with every request when in NODE_ENV=development
  • Caches results in memory when on NODE_ENV=production
  • Ability to return a normal or minified CSS file, depeding on the URL
  • Ability to pass a variable map, so that you can easily get variables from your database to your stylesheets
  • Easily flush SASS cache for individual or all routes

Setup

//       --- Standard Express setup ---

const express = require('expess');
const app = require('app');

//       --- The important bits ---

const sassMiddleware = require('@darius2652/sass-middleware')({
 // optional parameters, found below
});

app.use(sassMiddleware.Hook);

// Initialize sass-middleware before you add any routes or 

Usage

In your /sass or /scss directory, create a respective .sass or .scss file. For this example I went with /sass/my-file.sass.

In the HEAD section of your website, you can now link to this file with two methods, depending on your desired output:

<!-- Normal CSS output -->

<link href="stylesheet" href="/css/my-file.css">

<!-- Minified output -->

<link href="stylesheet" href="/css/my-file.min.css">

Optional Parameters

| Parameter | Use | | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | source | The folder where .sass or .scss files will be located. Defaults to /sass or /scss in your root directory | | variableMap | A JSON object containing key-value pairs which will be passed to the SASS compiler. Automatically prepended with $. Use !default to initialize values in the sass/scss files. | | forceMinifed | Always return minified CSS, regardless of wheter .min was added to the URL | | mode | Select between sass or scss. This will change the default source folder, the syntax used and the file extension the compiler searches for | | exposePartials | Whether to allow directly linking to files that have an underscore "_" in front of the file name (normally used for partial files) | | debug | One of three methods which can be called from within a sass or scss file, for debugging purposes. | | warn | One of three methods which can be called from within a sass or scss file, for debugging purposes. | | error | One of three methods which can be called from within a sass or scss file, for debugging purposes. |

Variables

In the example file, I have added the following variables to the variableMap parameter:

{
	"color-background": "#444",
 	"color-primary": "#00AAFF",
 	"header-size": "3em",
}

Using these variables (as can be seen in the example file my-file.sass), this is the output:

Variables Example Image

Methods

Flush Cache In production, it might be necessary to flush the cache of your SASS files without reloading the server. This will be necessary if your variableMap values change at any point.

Cache can be flushed for all generated SASS files,

Flushing can be called in two ways:

  • SassMiddleware.Flush()
  • In an express route, req.flushSass()

Installation


npm i -s @darius2652/sass-middleware

License

MIT