Add svg-sprite

This commit is contained in:
tkqubo
2015-09-13 06:38:35 +09:00
parent 7a3ca1f0b8
commit bcccc00325
2 changed files with 55 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
/// <reference path="svg-sprite.d.ts" />
import SVGSpriter = require('svg-sprite');
import * as fs from 'fs';
var config: any = null;
// Create spriter instance (see below for `config` examples)
var spriter = new SVGSpriter(config);
// Add SVG source files — the manual way ...
spriter.add('assets/svg-1.svg', null, fs.readFileSync('assets/svg-1.svg', {encoding: 'utf-8'}));
spriter.add('assets/svg-2.svg', null, fs.readFileSync('assets/svg-2.svg', {encoding: 'utf-8'}));
/* ... */
// Compile the sprite
spriter.compile(function(error: any, result: any) {
/* ... Write `result` files to disk or do whatever with them ... */
});
+36
View File
@@ -0,0 +1,36 @@
// Type definitions for svg-sprite
// Project: https://github.com/jkphl/svg-sprite
// Definitions by: Qubo <https://github.com/tkqubo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../vinyl/vinyl.d.ts" />
declare module "svg-sprite" {
import File = require('vinyl');
namespace sprite {
interface SVGSpriterConstructor {
new(config: any): SVGSpriter;
}
interface SVGSpriter {
add(file: string|File, name: string, svg: string): SVGSpriter;
compile(config: any, callback: CompileCallback): SVGSpriter;
compile(callback: CompileCallback): void;
getShapes(dest: string, callback: GetShapesCallback): void;
}
interface CompileCallback {
(error: any, result: any, data: any): any;
}
interface GetShapesCallback {
(error: any, result: File[]): any;
}
}
var sprite: sprite.SVGSpriterConstructor;
export = sprite;
}