How to use nib - 10 common examples

To help you get started, we’ve selected a few nib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / stylus / stylus-tests.ts View on Github external
* .set(setting, value)
 * https://github.com/LearnBoost/stylus/blob/master/docs/js.md#setsetting-value
 */
stylus(str)
    .set('filename', __dirname + '/test.styl')
    .set('paths', [__dirname, __dirname + '/mixins'])
    .render(function (err, css) {
        // logic
    });

/**
 * .include(path)
 * https://github.com/LearnBoost/stylus/blob/master/docs/js.md#includepath
 */
stylus(str)
    .include(require('nib').path)
    .include(process.env.HOME + '/mixins')
    .render(function (err, css) {
        // logic
    });

/**
 * .import(path)
 * https://github.com/LearnBoost/stylus/blob/master/docs/js.md#importpath
 */
stylus(str)
    .set('filename', __dirname + '/test.styl')
    .import('mixins/vendor')
    .render(function (err, css) {
        if (err) throw err;
        console.log(css);
    });
github cncjs / cncjs / gulp / tasks / stylus.js View on Github external
import gulp from 'gulp';
import stylus from 'gulp-stylus';
import sourcemaps from 'gulp-sourcemaps';
import nib from 'nib';

const stylusConfig = {
    src: ['src/web/**/*.styl'],
    dest: 'src/web/',
    options: {
        compress: true,
        // nib - CSS3 extensions for Stylus
        use: nib(),
        import: ['nib'] // no need to have a '@import "nib"' in the stylesheet
    }
};

export default (options) => {
    gulp.task('stylus', () => {
        return gulp.src(stylusConfig.src)
            .pipe(sourcemaps.init())
                .pipe(stylus(stylusConfig.options))
            .pipe(sourcemaps.write('/', { includeContent: false }))
            .pipe(gulp.dest(stylusConfig.dest));
    });
};
github walmartlabs / lumbar / lib / plugins / stylus-worker.js View on Github external
.set('compress', minimize);

  if (!stylusImages.plugin) {
    compiler.use(stylusImages(options.images));
  }

  compiler
    .use(pathScopes(msg))
    .include(lookupPath);

  if (styleRoot) {
    compiler.include(styleRoot);
  }
  if (useNib) {
    compiler
      .include(nib.path)
      .use(nib);
  }

  // Allow any plugins to do their thing
  _.each(plugins, function(plugin) {
    var data = plugin.data;

    plugin = require(plugin.plugin);
    plugin(compiler, data);
  });

  try {
    compiler.render(function(err, data) {
      var inputs = compiler.options._imports
              .concat(compiler.options.externals)
              .map(function(file) { return file.path || file; })
github tonistiigi / styler / lib / backend / console.js View on Github external
Console.prototype.stylusSetFileImports = function(file, imports) {
      var nibpath;
      if (!imports) {
        return delete this.imports[file];
      }
      nibpath = require("nib").path;
      return this.imports[file] = _.compact(_.map(imports, (function(_this) {
        return function(item) {
          var furl, name, path, url;
          if (item.path === STYLUS_FUNC_FILE) {
            return;
          }
          path = item.path;
          url = _this.pathToUrl(path);
          file = _this.files.find(function(f) {
            return f.srcpath === path;
          });
          if (!file) {
            furl = 0 === path.indexOf(nibpath) ? path.slice(nibpath.length + 1) : Math.random() * 1e6 | 0;
            name = _.last(path.split(/[\\\/]/));
            fs.stat(path, function(err, stat) {
              return _this.files.create({
github Gravebot / Gravebot / src / express.js View on Github external
app.get('/style/:file', (req, res) => {
    const css_path = path.join(__dirname, `../web/css/${req.params.file}`);
    if (nconf.get('NODE_ENV') !== 'development') {
      if (!fs.existsSync(css_path)) return res.redirect('/404');
      return res.sendFile(css_path);
    }

    const styl_path = css_path.replace(/css/g, 'styl');
    if (!fs.existsSync(styl_path)) return res.redirect('/404');
    stylus(fs.readFileSync(styl_path, 'utf8'))
      .set('src', path.join(__dirname, '../web/styl'))
      .set('filename', path.basename(styl_path))
      .set('compress', true)
      .use(nib())
      .render((err, css) => {
        if (err) {
          console.error(err);
          return res.status(500).send(err);
        }
        res.status(200).send(css);
      });
  });
github csanz / node-expressjs-example / config / config.js View on Github external
function compile(str, path) {
    return stylus(str)
      .set('filename', path)
      .include(nib.path)
  }
github sequelize / sequelize-admin / lib / router.js View on Github external
Router.prototype.serveStylus = function(req, res) {
  var path          = null
    , stylusContent = null

  path              = req.path.replace('/css/compiled', '/stylus').replace('.css', '.styl')
  path              = __dirname + '/..' + path.replace(this.options.endpoint, '')
  stylusContent     = fs.readFileSync(path).toString()

  stylus(stylusContent)
    .include(require('nib').path)
    .render(function(err, css) {
      if (err) {
        throw err
      }

      res.type('text/css')
      res.send(css)
      res.send(200)
    })
}
github feross / studynotes.org / lib / builder.js View on Github external
fs.readFile(inFilename, { encoding: 'utf8' }, function (err, source) {
    if (err) return cb(err)
    stylus(source, { filename: inFilename })
      .include(nib.path)
      .define('cdnOrigin', config.cdnOrigin)
      .set('compress', config.isProd)
      .render(function (err, css) {
        if (err) return cb(err)
        fs.writeFile(outFilename, css, cb)
      })
  })
}
github csanz / node-expressjs-example / lib / boot.js View on Github external
function compile(str, path) {
    return stylus(str)
      .set('filename', path)
      .include(nib.path);
  }
github csanz / node-expressjs-example / lib / environments / development.js View on Github external
function compileStylus (str, path) {
    return stylus(str)
      .set('filename', path)
      .include(nib.path)
  }

nib

Stylus mixins and utilities

MIT
Latest version published 3 years ago

Package Health Score

57 / 100
Full package analysis

Popular nib functions