grunt-svg-spriter
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -44,5 +44,7 @@ /** | ||
}, | ||
tasks: { | ||
compress: true, | ||
rasterize: true | ||
compression: { | ||
plugins: [ | ||
{removeTitle: true}, | ||
{removeDimensions: true} | ||
] | ||
} | ||
@@ -49,0 +51,0 @@ } |
{ | ||
"prefix": "icon", | ||
"delimiter": "--", | ||
"defaultColor": "#333", | ||
@@ -8,3 +6,2 @@ "sizes": [ | ||
"name": "xsm", | ||
"suffix": "xsm", | ||
"width": 16, | ||
@@ -15,3 +12,2 @@ "height": 16 | ||
"name": "sm", | ||
"suffix": "sm", | ||
"width": 24, | ||
@@ -22,3 +18,2 @@ "height": 24 | ||
"name": "default", | ||
"suffix": "", | ||
"width": 32, | ||
@@ -25,0 +20,0 @@ "height": 32 |
{ | ||
"name": "grunt-svg-spriter", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Creates svg sprite in symbols and creates png fallback", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -20,5 +20,15 @@ /** | ||
grunt.registerMultiTask('svg_spriter', 'Makes SVG sprites and PNG sprites from collection of SVG files', function () { | ||
grunt.registerMultiTask('svg_spriter', 'Makes SVG sprites and PNG fallbacks from collection of SVG files', function () { | ||
var getCollection = function (item) { | ||
var collection = {}; | ||
try { | ||
collection = JSON.parse(grunt.file.read(path.resolve(item.path.src + 'generator.json'))); | ||
} catch (e) { | ||
collection = {}; | ||
} | ||
return collection; | ||
}; | ||
var rasterize = function (done) { | ||
@@ -29,15 +39,6 @@ grunt.log.subhead('Rasterizing SVG files:'); | ||
items.forEach(function(item) { | ||
var collection = {}; | ||
try { | ||
collection = JSON.parse(grunt.file.read(path.resolve(item.path.src + 'generator.json'))); | ||
} catch (e) { | ||
collection.prefix = 'icon'; | ||
collection.delimiter = '--'; | ||
} | ||
var collection = getCollection(item); | ||
item.path.src = options.tasks.compress ? path.resolve(item.path.compressed) + '/' : path.resolve(item.path.src) + '/'; | ||
item.path.dest = path.resolve(item.path.variations) + '/'; | ||
item.collection = collection; | ||
}); | ||
@@ -70,3 +71,3 @@ | ||
var compress = function (done) { | ||
var compress = function (done, again) { | ||
grunt.log.subhead('Compressing SVG files:'); | ||
@@ -89,5 +90,10 @@ var svgo = new SVGO(options.compression); | ||
}, function() { | ||
grunt.log.ok('SVG files compressed'); | ||
done(); | ||
if (again) { | ||
grunt.log.ok('SVG files compressed'); | ||
done(); | ||
} else { | ||
compress(done, true); | ||
} | ||
}); | ||
}; | ||
@@ -103,7 +109,9 @@ | ||
compressed: 'compressed/', | ||
variations: 'png/', | ||
sprites: '' | ||
variations: 'png/' | ||
}, | ||
compression: { | ||
mergePaths: false | ||
plugins: [ | ||
{removeTitle: true}, | ||
{removeDimensions: true} | ||
] | ||
}, | ||
@@ -123,3 +131,2 @@ tasks: { | ||
src: files.cwd, | ||
dest: files.dest + options.folders.sprites, | ||
compressed: files.dest + options.folders.compressed, | ||
@@ -126,0 +133,0 @@ variations: files.dest + options.folders.variations |
265
14364
15