From 14ba13c215955ca8d22f37b49e0a60b3dd53e783 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sun, 6 Feb 2022 08:57:13 +0100 Subject: Added script to generate a sprite --- scripts/create_sprite.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 scripts/create_sprite.js (limited to 'scripts') diff --git a/scripts/create_sprite.js b/scripts/create_sprite.js new file mode 100644 index 0000000..3bd4cf4 --- /dev/null +++ b/scripts/create_sprite.js @@ -0,0 +1,36 @@ +const SVGSpriter = require('svg-sprite'); +const fs = require('fs'); +const path = require('path'); + +const args = process.argv.slice(2); +const sprite = args.pop(); + +const spriter = new SVGSpriter({ + mode: { + symbol: { + dest: "", + sprite, + } + }, + shape: { + transform: [] + } +}); + +for (const id of args) { + const file = path.resolve(__dirname, `../dist/${id}.svg`); + spriter.add(file, null, fs.readFileSync(file, { encoding: 'utf-8' })); +} + +spriter.compile((error, result) => { + if (error) { + console.error(error); + return; + } + for (var mode in result) { + for (var resource in result[mode]) { + console.log(result[mode][resource].path); + fs.writeFileSync(result[mode][resource].path, result[mode][resource].contents); + } + } +}); -- cgit v1.2.3-70-g09d2