-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild-assets.js
53 lines (51 loc) · 1.46 KB
/
build-assets.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
let svg2png = require('convert-svg-to-png');
let fs = require('fs');
let icon_sizes = [
{
size: [24,24],
path: (f) => `./app/App_resources/iOS/${f}.png`
},
{
size: [48,48],
path: (f) => `./app/App_resources/iOS/${f}@2x.png`
},
{
size: [72,72],
path: (f) => `./app/App_resources/iOS/${f}@3x.png`
},
{
size: [32,32],
path: (f) => `./app/App_resources/Android/src/main/res/drawable-mdpi/${f}.png`
},
{
size: [48,48],
path: (f) => `./app/App_resources/Android/src/main/res/drawable-hdpi/${f}.png`
},
{
size: [64,64],
path: (f) => `./app/App_resources/Android/src/main/res/drawable-xhdpi/${f}.png`
},
{
size: [96,96],
path: (f) => `./app/App_resources/Android/src/main/res/drawable-xxhdpi/${f}.png`
},
{
size: [128,128],
path: (f) => `./app/App_resources/Android/src/main/res/drawable-xxxhdpi/${f}.png`
}
]
for (let f of fs.readdirSync('./assets/icons')) {
console.log("found "+f);
if (f.endsWith('.svg')) {
for (let transform of icon_sizes) {
let outFile = transform.path(f.replace(/\.svg$/i, ''));
svg2png.convertFile(`./assets/icons/${f}`,
{
width: transform.size[0],
height: transform.size[1],
outputFilePath: outFile
})
console.log(`Created ${outFile}`);
}
}
}