-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogrammatic.ts
62 lines (58 loc) · 1.23 KB
/
programmatic.ts
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
54
55
56
57
58
59
60
61
62
import { parseAllAssets, AssetResizerConfig } from "asset-resizer";
// alt: const { parseAllAssets } = require("asset-resizer");
// With default config file
parseAllAssets().then(() => {
console.log("done");
});
// With specified config file
parseAllAssets("custom.config.js").then(() => {
console.log("done");
});
// With programmatic config
const config: AssetResizerConfig = {
baseUrl: ".",
inputDir: "assets",
outputDir: "build",
flatten: true,
assets: [
{
file: "300x300.svg",
output: [
{
file: "50x50.png",
width: 50,
},
{
file: "200x100.png",
width: 200,
height: 100,
},
{
file: "200x100-contain.png",
width: 200,
height: 100,
fit: "contain",
},
],
},
{
file: "subdir/500x400.svg",
output: [
{
file: "icon.jpg",
width: 256,
fit: "cover",
},
{
file: "large.jpg",
width: 800,
height: 600,
fit: "outside",
},
],
},
],
};
parseAllAssets(config).then(() => {
console.log("done");
});