Skip to content

Commit d5ff471

Browse files
committed
all: optimize images
1 parent 333f769 commit d5ff471

24 files changed

+69
-16
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"tslib": "^2.3.1",
3737
"typescript": "~4.6.2",
3838
"vite": "^3.0.4",
39+
"vite-imagetools": "^4.0.5",
3940
"vite-plugin-image-presets": "^0.3.2",
4041
"web-vitals": "^2.1.4"
4142
},
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/lib/components/index/BigFeatureBox.svelte

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
export let img: string | undefined;
3+
export let srcset: string | undefined;
34
export let title: string;
45
export let rainbow = false;
56
export let reverse = false;
@@ -21,6 +22,13 @@
2122
<img
2223
src={img}
2324
class="float-left m-4 h-20 max-w-[8rem] flex-shrink-0 md:float-none md:m-0 md:h-auto md:max-w-[12rem] lg:max-w-[14rem]"
25+
width="150"
26+
/>
27+
{:else if srcset}
28+
<img
29+
{srcset}
30+
class="float-left m-4 h-20 max-w-[8rem] flex-shrink-0 md:float-none md:m-0 md:h-auto md:max-w-[12rem] lg:max-w-[14rem]"
31+
width="150"
2432
/>
2533
{/if}
2634

src/lib/components/index/FeatureBox.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<script lang="ts">
2-
export let img: string;
2+
export let srcset: string;
33
export let title: string;
44
export let pill: string;
55
</script>
66

77
<div
88
class="flex items-start gap-4 rounded-xl bg-violet-100 p-4 md:items-center md:gap-8 md:p-8 lg:mx-0 lg:w-full lg:gap-16"
99
>
10-
<img src={img} class="h-20 flex-shrink-0 md:h-40 " />
10+
<img {srcset} class="h-20 flex-shrink-0 md:h-40 " />
1111

1212
<div class="flex flex-col items-end gap-4 lg:flex-row lg:items-end lg:gap-16">
1313
<div class="flex flex-col gap-2 text-gray-600">

src/routes/[email protected]

+8-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
import Button from '$lib/Button.svelte';
1111
1212
import { FeatureList, BigFeatureBox, FeatureBox, Hero } from '$lib/components/index';
13+
import armadilloGraphHD from '$lib/armadillo/graph.png?preset=hd&srcset';
14+
import armadilloPlug from '$lib/armadillo/plug.png?preset=thumbnail&srcset';
15+
import armadilloDataScientist from '$lib/armadillo/data-scientist.png?preset=thumbnail&srcset';
16+
import armadilloCoffee from '$lib/armadillo/coffee-2.png?preset=thumbnail&srcset';
1317
</script>
1418

1519
<Hero>
@@ -39,12 +43,12 @@
3943
</slot>
4044

4145
<slot slot="right">
42-
<img src="/armadillo/graph.png" />
46+
<img srcset={armadilloGraphHD} />
4347
</slot>
4448
</Hero>
4549

4650
<FeatureList>
47-
<BigFeatureBox title="DORA Metrics" img="/armadillo/data-scientist.png" reverse={true}>
51+
<BigFeatureBox title="DORA Metrics" srcset={armadilloDataScientist} reverse={true}>
4852
<slot slot="content">
4953
<p>
5054
Engineering teams love to track their DORA metrics (<a
@@ -63,7 +67,7 @@
6367
</slot>
6468
</BigFeatureBox>
6569

66-
<BigFeatureBox title="Not a dashboard" img="/armadillo/plug.png">
70+
<BigFeatureBox title="Not a dashboard" srcset={armadilloPlug}>
6771
<slot slot="content">
6872
<p>
6973
There are many companies that will sell you dashboards, but not doing much to <em
@@ -96,7 +100,7 @@
96100
</slot>
97101
</BigFeatureBox>
98102

99-
<FeatureBox title="Start Now" img="/armadillo/coffee-2.png">
103+
<FeatureBox title="Start Now" srcset={armadilloCoffee}>
100104
<slot slot="content">
101105
<p>
102106
Get started with Codeball for free today <span class="text-gray-400"

src/routes/[email protected]

+14-6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
} from '$lib/components/index';
2121
import Button from '$lib/Button.svelte';
2222
23+
import armadilloCoffee from '$lib/armadillo/coffee-2.png?preset=thumbnail&srcset';
24+
import armadilloPingPong from '$lib/armadillo/pingpong-2.png?preset=thumbnail&srcset';
25+
import armadilloTrackAndField from '$lib/armadillo/track-and-field.png?preset=thumbnail&srcset';
26+
import armadilloGraph from '$lib/armadillo/graph.png?preset=thumbnail&srcset';
27+
28+
import armadilloAtTheComputerHD from '$lib/armadillo/at-the-computer-2.png?preset=hd&srcset';
29+
import armadilloBigOfficeHD from '$lib/armadillo/big-office.png?preset=hd&srcset';
30+
2331
export let login: string | null;
2432
</script>
2533

@@ -56,7 +64,7 @@
5664
</div>
5765
</slot>
5866
<slot slot="right">
59-
<img src="/armadillo/at-the-computer-2.png" />
67+
<img srcset={armadilloAtTheComputerHD} />
6068
<Logos />
6169
</slot>
6270
</Hero>
@@ -79,12 +87,12 @@
7987
</div>
8088
<img
8189
class="select-none md:-mt-[6rem] lg:-mr-[44rem] lg:-mt-[16rem] xl:-mr-[32rem]"
82-
src="/armadillo/big-office.png"
90+
srcset={armadilloBigOfficeHD}
8391
/>
8492
</div>
8593

8694
<FeatureList>
87-
<FeatureBox title="Codeball Approver" img="/armadillo/coffee-2.png">
95+
<FeatureBox title="Codeball Approver" srcset={armadilloCoffee}>
8896
<slot slot="content">
8997
<p>
9098
Approver uses advanced Artificial Intelligence to grade Pull Requests, and will approve Pull
@@ -101,7 +109,7 @@
101109
</div>
102110
</FeatureBox>
103111

104-
<FeatureBox title="Codeball Suggester" img="/armadillo/pingpong-2.png" pill="BETA">
112+
<FeatureBox title="Codeball Suggester" srcset={armadilloPingPong} pill="BETA">
105113
<slot slot="content">
106114
<p>
107115
The Suggester is powered by OpenAI Codex and converts comment feedback in Code Review to
@@ -117,7 +125,7 @@
117125
</div>
118126
</FeatureBox>
119127

120-
<FeatureBox title="Really fast, running on GitHub Actions" img="/armadillo/track-and-field.png">
128+
<FeatureBox title="Really fast, running on GitHub Actions" srcset={armadilloTrackAndField}>
121129
<slot slot="content">
122130
<p>
123131
All of our tools runs on GitHub Actions, making it easy as <strong>⌘+V</strong> to setup, and
@@ -130,7 +138,7 @@
130138
</div>
131139
</FeatureBox>
132140

133-
<FeatureBox title="Not a dashboard" img="/armadillo/graph.png">
141+
<FeatureBox title="Not a dashboard" srcset={armadilloGraph}>
134142
<slot slot="content">
135143
<p>
136144
Collecting data and rendering a graph is easy &mdash; making you a better coder and

vite.config.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import imagePresets, { densityPreset } from 'vite-plugin-image-presets';
1+
import imagePresets, { densityPreset, widthPreset } from 'vite-plugin-image-presets';
22
import { sveltekit } from '@sveltejs/kit/vite';
33

44
const withRoundBorders = (image) => {
@@ -29,6 +29,22 @@ const config = {
2929
webp: { quality: 40 },
3030
png: { quality: 40 }
3131
}
32+
}),
33+
34+
thumbnail: widthPreset({
35+
loading: 'lazy',
36+
widths: [50, 300],
37+
formats: {
38+
webp: { quality: 90 }
39+
}
40+
}),
41+
42+
hd: widthPreset({
43+
loading: 'lazy',
44+
widths: [50, 300, 1024],
45+
formats: {
46+
webp: { quality: 90 }
47+
}
3248
})
3349
}),
3450
sveltekit()

yarn.lock

+19-3
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
resolved "https://registry.yarnpkg.com/@rgossiaux/svelte-headlessui/-/svelte-headlessui-1.0.2.tgz#9493251a40cd56d8bdc8f0f64623d886bb872b1e"
145145
integrity sha512-sauopYTSivhzXe1kAvgawkhyYJcQlK8Li3p0d2OtcCIVprOzdbard5lbqWB4xHDv83zAobt2mR08oizO2poHLQ==
146146

147-
"@rollup/pluginutils@^4.2.1":
147+
"@rollup/pluginutils@^4.1.2", "@rollup/pluginutils@^4.2.1":
148148
version "4.2.1"
149149
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-4.2.1.tgz#e6c6c3aba0744edce3fb2074922d3776c0af2a6d"
150150
integrity sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==
@@ -1472,6 +1472,13 @@ ignore@^5.1.8, ignore@^5.2.0:
14721472
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
14731473
integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==
14741474

1475+
imagetools-core@^3.0.3:
1476+
version "3.0.3"
1477+
resolved "https://registry.yarnpkg.com/imagetools-core/-/imagetools-core-3.0.3.tgz#ed454c47abb21e85c272798a8a47b569ca344c72"
1478+
integrity sha512-JK7kb0ezkzD27zQgZs7mtRd7DekC+/RTePjIzPsuBAp3S/Z17wNt+6TSEdDJRQSV5xiGV+SOG00weSGVdX3Xig==
1479+
dependencies:
1480+
sharp "^0.30.0"
1481+
14751482
import-fresh@^3.0.0, import-fresh@^3.2.1:
14761483
version "3.3.0"
14771484
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b"
@@ -1637,7 +1644,7 @@ magic-string@^0.25.7:
16371644
dependencies:
16381645
sourcemap-codec "^1.4.8"
16391646

1640-
magic-string@^0.26.2:
1647+
magic-string@^0.26.0, magic-string@^0.26.2:
16411648
version "0.26.2"
16421649
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.26.2.tgz#5331700e4158cd6befda738bb6b0c7b93c0d4432"
16431650
integrity sha512-NzzlXpclt5zAbmo6h6jNc8zl2gNRGHvmsZW4IvZhTC4W7k4OlLP+S5YLussa/r3ixNT66KOQfNORlXHSOy/X4A==
@@ -2208,7 +2215,7 @@ set-cookie-parser@^2.4.8:
22082215
resolved "https://registry.yarnpkg.com/set-cookie-parser/-/set-cookie-parser-2.5.1.tgz#ddd3e9a566b0e8e0862aca974a6ac0e01349430b"
22092216
integrity sha512-1jeBGaKNGdEq4FgIrORu/N570dwoPYio8lSoYLWmX7sQ//0JY08Xh9o5pBcgmHQ/MbsYp/aZnOe1s1lIsbLprQ==
22102217

2211-
2218+
[email protected], sharp@^0.30.0:
22122219
version "0.30.7"
22132220
resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.30.7.tgz#7862bda98804fdd1f0d5659c85e3324b90d94c7c"
22142221
integrity sha512-G+MY2YW33jgflKPTXXptVO28HvNOo9G3j0MybYAHeEmby+QuD2U98dT6ueht9cv/XDqZspSpIhoSW+BAKJ7Hig==
@@ -2551,6 +2558,15 @@ v8-compile-cache@^2.0.3:
25512558
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"
25522559
integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==
25532560

2561+
vite-imagetools@^4.0.5:
2562+
version "4.0.5"
2563+
resolved "https://registry.yarnpkg.com/vite-imagetools/-/vite-imagetools-4.0.5.tgz#64892745b149f05e2a4158db3445c88baa6de901"
2564+
integrity sha512-Blh5Fl5tbBGkLFM+BCxtN5zoagBGedEHI+VH5GmUdpBJV7AGpuG9Y8rbTEHzwYP6mg3+nl4mgz3UaFiYhQU1cA==
2565+
dependencies:
2566+
"@rollup/pluginutils" "^4.1.2"
2567+
imagetools-core "^3.0.3"
2568+
magic-string "^0.26.0"
2569+
25542570
vite-plugin-image-presets@^0.3.2:
25552571
version "0.3.2"
25562572
resolved "https://registry.yarnpkg.com/vite-plugin-image-presets/-/vite-plugin-image-presets-0.3.2.tgz#706eec875608bd1590c197bc5d9b583e74e38235"

0 commit comments

Comments
 (0)