sassify
Browserify middleware for adding required styles to the page.
Last updated 10 years ago by dguttman .
BSD-2-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ npm install sassify 
SYNC missed versions from official npm registry.

sassify

Simple middleware and method for Browserify to add Sass styles to the browser.

Build Status Dependency Status devDependency Status

Currently breaks in some cases on node 0.11.x with latest version (2.0.1) of node-sass as documented in node-sass issue #550. This is also the reason why node 0.11 is currently not supported. Use at your own risk (though no actual risk is involved, it might just not work).

Example

If you have a file entry.js that you want to require some css from style.scss:

style.scss:

body {
  background: pink;
}

entry.js:

require('./style.scss');

console.log('The background is pink!')

Or indented Sass syntax may be used with the .sass extension:

require('./style.sass');

Install sassify into your app:

$ npm install sassify

When you compile your app, just pass -t sassify to browserify:

$ browserify -t sassify entry.js > bundle.js

Gulp task example

...or you can do it using a gulp task.

var gulp = require('gulp');
var browserify = require('browserify');
var sassify = require('sassify');
var source = require('vinyl-source-stream');

gulp.task('build', function(done) {
  var result = browserify({})
      .transform(sassify, {
        base64Encode: false, // Use base64 to inject css
        sourceMap: false, // Add source map to the code
        // when 'no-auto-inject' is set to `true`, `require('./style.scss')` won't inject styles
        // it will simply return the css as a string
        'no-auto-inject': false
      });

  result.add('./entry.js');
  result.bundle()
      .pipe(source('output.js'))
      .pipe(gulp.dest('./'))
      .on('end', function(err) {
        if (err) {
          done(err);
        } else {
          done();
        }
      });
});

Imports

Sass allows one to @import other Sass files. This module synchronously imports those dependencies at the time of the bundling. It looks for the imported files in both the directory of the parent file and the folder where the module itself lives, so it should work so long as the paths in the @import commands are correct relative to the importing file, as usual. It is not currently tested for recursive importing.

Install

sassify

License

MIT

Current Tags

  • 4.0.1                                ...           latest (7 years ago)

23 Versions

  • 4.0.1                                ...           7 years ago
  • 3.0.0                                ...           7 years ago
  • 2.0.0                                ...           8 years ago
  • 1.0.0                                ...           9 years ago
  • 0.10.0                                ...           9 years ago
  • 0.5.3                                ...           9 years ago
  • 0.9.1                                ...           10 years ago
  • 0.9.0                                ...           10 years ago
  • 0.8.0                                ...           10 years ago
  • 0.7.0                                ...           10 years ago
  • 0.5.2                                ...           10 years ago
  • 0.6.0                                ...           10 years ago
  • 0.5.1                                ...           11 years ago
  • 0.5.0                                ...           11 years ago
  • 0.4.1                                ...           11 years ago
  • 0.4.0                                ...           11 years ago
  • 0.3.1                                ...           11 years ago
  • 0.3.0                                ...           11 years ago
  • 0.2.0                                ...           11 years ago
  • 0.1.2                                ...           11 years ago
  • 0.1.1                                ...           11 years ago
  • 0.1.0                                ...           11 years ago
  • 0.0.0                                ...           12 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (4)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE