Add gulp-svg-sprite

This commit is contained in:
tkqubo 2015-09-17 06:00:34 +09:00
parent 5f48028783
commit de0d7f205e
3 changed files with 75 additions and 2 deletions

View File

@ -0,0 +1,51 @@
/// <reference path="gulp-svg-sprite.d.ts" />
/// <reference path="../gulp/gulp.d.ts" />
/// <reference path="../svg-sprite/svg-sprite.d.ts" />
import svgSprite = require('gulp-svg-sprite');
import spriter = require('svg-sprite');
import gulp = require('gulp')
let config: spriter.Config;
// Basic configuration example
config = {
mode : {
css : { // Activate the «css» mode
render : {
css : true // Activate CSS output (with default options)
}
}
}
};
gulp.src('**/*.svg', {cwd: 'path/to/assets'})
.pipe(svgSprite(config))
.pipe(gulp.dest('out'));
config = {
shape : {
dimension : { // Set maximum dimensions
maxWidth : 32,
maxHeight : 32
},
spacing : { // Add padding
padding : 10
},
dest : 'out/intermediate-svg' // Keep the intermediate files
},
mode : {
view : { // Activate the «view» mode
bust : false,
render : {
scss : true // Activate Sass output (with default options)
}
},
symbol : true // Activate the «symbol» mode
}
};
gulp.src('**/*.svg', {cwd: 'path/to/assets'})
.pipe(svgSprite(config))
.pipe(gulp.dest('out'));

22
gulp-svg-sprite/gulp-svg-sprite.d.ts vendored Normal file
View File

@ -0,0 +1,22 @@
// Type definitions for gulp-svg-sprite
// Project: https://github.com/jkphl/gulp-svg-sprite
// Definitions by: Qubo <https://github.com/tkqubo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
/// <reference path="../svg-sprite/svg-sprite.d.ts" />
declare module "gulp-svg-sprite" {
import spriter = require('svg-sprite');
namespace svgSprite {
interface SvgSprite {
(options?: spriter.Config): NodeJS.ReadWriteStream;
}
}
var svgSprite: svgSprite.SvgSprite;
export = svgSprite;
}

View File

@ -291,12 +291,12 @@ declare module "svg-sprite" {
* which all reside in the directory tmpl/css. Example: {css: true, scss: {dest: '_sprite.scss'}}
* @default {}
*/
render?: { [key: string]: RenderingConfiguration };
render?: { [key: string]: RenderingConfiguration|boolean };
/**
* Enabling this will trigger the creation of an HTML document demoing the usage of the sprite. Please see below for details on [rendering configurations](#rendering-configurations).
* @default false
*/
example?: RenderingConfiguration;
example?: RenderingConfiguration|boolean;
/**
* Specify svg-sprite which output mode to use with this configuration
*/