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

sass-include-paths

v4.10.0

Published

Generates include paths for node-sass for packages from popular package managers like npm, bower, ruby gem, ruby bundler.

Downloads

255

Readme

sass-include-paths

Generates include paths for node-sass for packages from popular package managers like npm, bower, ruby gem, ruby bundler.

david

NPM

The generated array with the include paths can be passed to node-sass.

Allows interoperability between sass variants, ruby sass, libsass and sass-eyeglass (libsass + eyeglass)

Async/Sync

This module offers an async and a sync version of each function. The async version returns a thenable (Promise based) for easier chaining. The sync version is intended for being used in tools like Gulp where this doesn't matter in a task.

Methods

node modules

For node modules that contain SCSS/SASS files.

nodeModulesSync()

Sync version, returns the array directly.

nodeModules()

Async version, returns a theneable.

bower components

For bower components that contain SCSS/SASS files.

bowerComponentsSync()

Sync version, returns the array directly.

bowerComponents()

Async version, returns a theneable.

bundled ruby gems

For bundled ruby gems installed in folder by bundler (default is ./vendor/bundle) that contain SCSS/SASS files.

rubyGemsBundleSync()

Sync version, returns the array directly.

rubyGemsBundle()

Async version, returns a theneable.

system/global ruby gems

For ruby gems installed on current (activated/available) ruby environment (system/globally installed gems) that contain SCSS/SASS files.

rubyGemsSync()

Sync version, returns the array directly.

rubyGems()

Async version, returns a theneable.

Usage

Require this module and optionally define an array of include paths, either empty or already with some paths to include:

var sassIncl = require('sass-include-paths'),
    scssIncludePaths = [];

When the module functions are invoked outside the task scope, the scan is run only once when gulp is started, notably when using gulp-watch. This spares extra scans each time workspace files are changed. When packages, gems or bower components are changed, gulp watch has to be restarted for a rescan.

For importing sass/scss files from sass/eyeglass npm packages...

using gulp-ruby-sass (ruby sass)

[...]
scssIncludePaths = [] // additional include paths
  .concat(sassIncl.nodeModulesSync());
[...]
  rubySass(srcAssets.scss + '/*.scss', {
    loadPath: scssIncludePaths
  })
[...]

As gulp-ruby-sass (ruby-sass) already imports sass/scss files from ruby gems (autorequired by Gemfile or explicitly required in compass config.rb or elsewhere), there is no need to pass paths to these, too.

For importing sass/scss files from plain or eyeglass npm packges and from ruby gems and local bundle...

using gulp-sass (plain libsass)

[...]
scssIncludePaths = [] // additional include paths
  .concat(sassIncl.nodeModulesSync())
  .concat(sassIncl.rubyGemsSync())
  .concat(sassIncl.rubyGemsBundleSync());
[...]
  .pipe(plugins.sass({
    includePaths: scssIncludePaths
  }))
[...]

One could argue using a custom importer for node-sass instead, but currently there are no custom importers that scan node_modules/ because in most opinions this should be handled by eyeglass (libsass + eyeglass) instead, however, even using eyeglass, there is still an use case (see further below).

For importing sass/scss files from plain npm packages and from ruby gems and local bundle...

using eyeglass (libsass + eyeglass)

[...]
// Outside the gulp task
scssIncludePaths = [] // additional include paths
  .concat(sassIncl.nodeModulesSync())
  .concat(sassIncl.rubyGemsSync())
  .concat(sassIncl.rubyGemsBundleSync()):
[...]
var eyeglass = new Eyeglass({
  includePaths: scssIncludePaths
});
[...]

One use case to also add node_module paths when using eyeglass is to be able to import npm packages that haven't been made eyeglass-ready yet. Though it may work fine using this module, please still consider creating an issue to inform the package creator that eyeglass metadata is still missing for the package.

CLI/sassc usage

A cli wrapper comes with this module which can generate the list of include paths to be used on cli. For sassc-compatible options output, pass the --sassc switch. Example:

$ npm install -g sass-include-paths
$ sassc $(sassIncludePaths --sassc --node_modules --bower_components) [...]

Note: $(...) executes the command and re-uses its stdout.

Development

In order to run the tests, npm, bower and ruby gem/bundler have to be available. bower will be installed as development dependency of this package. For consistent tests, the ruby and node versions have been locked using rvm/nvm config files, so both or similar tools have to be installed to ensure the right versions and isolation.

./test/prepare.sh can be run after npm install for quickly installing the bower dependencies and ruby bundle.