sass-npm

1.0.2 • Public • Published

sass-npm

A SASS importer that allows you to import SASS using an npm module name.

This allows you to keep your SASS files inside your frontend npm modules.

If you're using browserify, you probably want this!

Contributing

I just wrote this because I needed it. Pull requests gladly accepted!

Installation

npm install sass-npm

Usage

sass-npm currently just looks for style.scss inside the top level of a npm module to determine whether to load it. This is fine for me right now, but we could change this in future - let me know if you have suggestions!

In your sass file:

// Since node_modules/npm-module-name/style.scss exists, this will be imported.
@import "npm-module-name";

// Since just-a-sass-file isn't an installed npm module, it will be imported as a regular SCSS file.
@import "just-a-sass-file";

I normally use gulp-sass (which has the same 'importer' option as regular SASS)

	var gulp = require('gulp'),
		sass = require('gulp-sass'),
		sassNpm = require('sass-npm')();

Then, in your .pipe(sass()), add the importer as an option:

.pipe(sass({
	paths: ['public/scss'],
	importer: sassNpm.importer,
}))

Author

Mike MacCana mike@certsimple.com

Package Sidebar

Install

npm i sass-npm

Weekly Downloads

4

Version

1.0.2

License

ISC

Last publish

Collaborators

  • mikemaccana