How to use the svg-sprite.createSprite function in svg-sprite

To help you get started, we’ve selected a few svg-sprite 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 jkphl / node-iconizr / lib / iconizr.js View on Github external
error.errno			= 1391852448;
		return error;
	}
	
	// Keep the intermediate files
	options				= _.extend({}, defaultOptions, options || {});
	options.verbose		= Math.max(0, Math.min(3, parseInt(options.verbose, 10) || 0));
	
	// Temporarily alter the configuration options to keep intermediate files and suppress all output rendering
	options._keep		= options.keep;
	options.keep		= 1;
	options._render		= _.extend({css: true}, options.render);
	options.render		= {css: false};
	
	// Create the SVG sprite
	var sprite			= SVGSprite.createSprite(inputDir, outputDir, options, function(error, results) {
		
		// Restore configuration options
		results.options	= restoreOptions(results.options);
		
		// If an error occured while creating the SVG sprite: Abort
		if (error) {
			callback(error, results);
			
		// Else: Create icon kit
		} else {
			new Iconizr(results).createIconKit(callback);
		}
	});
	
	// In case of an error: Return it
	if (util.isError(sprite)) {
github jkphl / grunt-svg-sprite / tasks / svgsprite.js View on Github external
this.files.forEach(function(file) {
			var indir		= file.src.shift() || './',
			outdir			= util.isArray(file.dest) ? file.dest.shift() : ('' + file.dest),
			done			= that.async();
			
			console.log('Building SVG sprite from directory "%s" ...', indir);
			
			SVGSprite.createSprite(indir, outdir, options, function(error, results) {
				if (error) {
					console.error(error);
				} else {
					for (var file in results.files) {
						grunt.log.writeln(chalk.green('✔ ') + file + chalk.gray(' (' + results.files[file] + ' bytes)'));
					}
				}
				done();
			});
		});
	});

svg-sprite

SVG sprites & stacks galore — A low-level Node.js module that takes a bunch of SVG files, optimizes them and bakes them into SVG sprites of several types along with suitable stylesheet resources (e.g. CSS, Sass, LESS, Stylus, etc.)

MIT
Latest version published 1 month ago

Package Health Score

80 / 100
Full package analysis