summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2022-02-06 08:57:13 +0100
committerVolpeon <git@volpeon.ink>2022-02-06 08:57:13 +0100
commit14ba13c215955ca8d22f37b49e0a60b3dd53e783 (patch)
tree18ec5bf4c005c2d75d1974cf401dc4a30f99895c /scripts
parentInclude compiled files (diff)
downloadiro-icons-14ba13c215955ca8d22f37b49e0a60b3dd53e783.tar.gz
iro-icons-14ba13c215955ca8d22f37b49e0a60b3dd53e783.tar.bz2
iro-icons-14ba13c215955ca8d22f37b49e0a60b3dd53e783.zip
Added script to generate a sprite
Diffstat (limited to 'scripts')
-rw-r--r--scripts/create_sprite.js36
1 files changed, 36 insertions, 0 deletions
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 @@
1const SVGSpriter = require('svg-sprite');
2const fs = require('fs');
3const path = require('path');
4
5const args = process.argv.slice(2);
6const sprite = args.pop();
7
8const spriter = new SVGSpriter({
9 mode: {
10 symbol: {
11 dest: "",
12 sprite,
13 }
14 },
15 shape: {
16 transform: []
17 }
18});
19
20for (const id of args) {
21 const file = path.resolve(__dirname, `../dist/${id}.svg`);
22 spriter.add(file, null, fs.readFileSync(file, { encoding: 'utf-8' }));
23}
24
25spriter.compile((error, result) => {
26 if (error) {
27 console.error(error);
28 return;
29 }
30 for (var mode in result) {
31 for (var resource in result[mode]) {
32 console.log(result[mode][resource].path);
33 fs.writeFileSync(result[mode][resource].path, result[mode][resource].contents);
34 }
35 }
36});