How to use the stylus.url function in stylus

To help you get started, we’ve selected a few stylus 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 gruntjs / grunt-contrib-stylus / tasks / stylus.js View on Github external
_.each(options, function(value, key) {
      if (key === 'urlfunc') {
        // Custom name of function for embedding images as Data URI
        if (_.isString(value)) {
          s.define(value, stylus.url());
        } else {
          s.define(value.name, stylus.url({
            limit: value.limit !== null ? value.limit : 30000,
            paths: value.paths ? value.paths : []
          }));
        }
      } else if (key === 'use') {
        value.forEach(function(func) {
          if (_.isFunction(func)) {
            s.use(func());
          }
        });
      } else if (key === 'define') {
        for (var defineName in value) {
          s.define(defineName, value[defineName], shouldUseRawDefine(defineName));
        }
github buildjs / interleave / lib / preprocessors / stylus.js View on Github external
exports.process = function(input, callback) {
    var interleave = this,
        opts = this.opts.stylus || {},
        plugins = opts.plugins || {};
    
    try {
        var stylus = require('stylus'),
            renderer = stylus(input.content, { filename: input.file });

        // if we have plugins use them
        for (var key in plugins) {
            renderer.use(plugins[key]());
        }
        
        if (opts.urlEmbed) {
            renderer.define('url', stylus.url());
        }
        
        renderer.render(function(err, css) {
            if (err) {
                callback('could not render: ' + err.message);
            }
            else {
                callback(null, {
                    file: (input.file || '').replace(/\.styl$/, '.css'),
                    content: css
                });
            }
        });
    }
    catch (e) {
        callback(new Error('stylus not installed, run \'npm install stylus\' to add the plugin'));
github quilljs / quill / scripts / server.js View on Github external
fs.readFile('./src/themes/snow/snow.styl', function(err, data) {
    var s = stylus(data.toString());
    s.include('./src/themes/snow');
    s.define('url', stylus.url());
    s.render(function(err, css) {
      res.write(css);
      res.end();
    })
  });
});
github ad-si / bitcoinate / jakefile.js View on Github external
function buildMinifiedCss (string) {

  let cssString = ''

  stylus(string)
    .set('compress', true)
    .use(nib())
    .import('nib')
    .define('url', stylus.url())
    .render((err, css) => {
      if (err) throw err
      cssString = css.replace(/\n/g, '')
    })

  return cssString
}
github tamiadev / tamia / config / webpack.config.js View on Github external
{
				test: /\.styl$/,
				loaders: [
					'style',
					'css',
					'postcss',
					'stylus',
				],
			},
		],
	},

	stylus: {
		define: {
			DEBUG: true,
			embedurl: require('stylus').url(),
		},
	},

	postcss: function() {
		return [
			autoprefixer({
				browsers: ['last 2 versions', 'not ie < 11', 'not ie_mob < 11'],
			}),
		];
	},
};
github walmartlabs / thorax / generator / app / styles / plugins / url-import.js View on Github external
return function(style) {
    style.define('url', stylus.url());
  };
};
github fengxinming / wepy-compiler-stylus / index.js View on Github external
break;
        case 'include':
          includes.push(v);
          break;
        case 'import':
          imports.push(v);
          break;
        case 'url':
          let obj;
          if (typeof v === 'string') {
            obj = {};
            obj[v] = stylus.url();
            Object.assign(defines, obj);
          } else {
            obj = {};
            obj[v.name] = stylus.url({
              limit: v.limit != null ? v.limit : 30000,
              paths: v.paths || []
            });
            Object.assign(defines, obj);
          }
          break;
        case 'includeCSS':
          k = 'include css';
        default:
          sets[k] = v;
      }
    });
github sindresorhus / broccoli-stylus / index.js View on Github external
opts.urlFn.forEach(function (el) {
			s.define(el, stylus.url());
		});
	}
github 2gis / mapsapi / build / gulp-stylus / index.js View on Github external
options.urlFunc.forEach(function(args){
        s.define(args, stylus.url());
      });
    }
github walmartlabs / thorax / generator / app / styles / plugins / url-import@2x.js View on Github external
return function(style) {
    style.define('url', stylus.url({res: 2}));
  };
};