diff options
author | Volpeon <git@volpeon.ink> | 2022-02-06 08:57:13 +0100 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2022-02-06 08:57:13 +0100 |
commit | 14ba13c215955ca8d22f37b49e0a60b3dd53e783 (patch) | |
tree | 18ec5bf4c005c2d75d1974cf401dc4a30f99895c /scripts | |
parent | Include compiled files (diff) | |
download | iro-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.js | 36 |
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 @@ | |||
1 | const SVGSpriter = require('svg-sprite'); | ||
2 | const fs = require('fs'); | ||
3 | const path = require('path'); | ||
4 | |||
5 | const args = process.argv.slice(2); | ||
6 | const sprite = args.pop(); | ||
7 | |||
8 | const spriter = new SVGSpriter({ | ||
9 | mode: { | ||
10 | symbol: { | ||
11 | dest: "", | ||
12 | sprite, | ||
13 | } | ||
14 | }, | ||
15 | shape: { | ||
16 | transform: [] | ||
17 | } | ||
18 | }); | ||
19 | |||
20 | for (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 | |||
25 | spriter.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 | }); | ||