sn

sass-npm

Import SASS files from npm modules

Showing:

Popularity

Downloads/wk

50

GitHub Stars

7

Maintenance

Last Commit

6yrs ago

Contributors

1

Package

Dependencies

0

Size (min+gzip)

0.4KB

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

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-import')();

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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100