Skip to content

Commit

Permalink
♻️ Image optimisation to webp (#79)
Browse files Browse the repository at this point in the history
<!-- describe the change, why is it needed and what does it accomplish
as per https://ssw.com.au/rules/write-a-good-pull-request/ -->

Fixes #75 

<!-- Add done video, screenshots as per
https://ssw.com.au/rules/record-a-quick-and-dirty-done-video/-->
Added a step in the build process to convert jpg/png to webp.
<img width="811" alt="image"
src="https://github.com/SSWConsulting/SSW.Dory/assets/41951199/dc8e717f-bd98-4175-960b-24fcb8a0b242">
**Figure: Images now in webp format**

<!-- As per rule https://www.ssw.com.au/rules/over-the-shoulder-prs -->
<!-- Getting the PR merged is part of the task - Call someone to review
your changes to get them merged ASAP -->
  • Loading branch information
Jord-Gui authored Oct 15, 2023
2 parents be0b05a + 7d16ca4 commit 8bbd12d
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 14 deletions.
4 changes: 4 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

# next-image-export-optimizer
/public/next-image-export-optimizer-hashes.json
/public/nextImageExportOptimizer
17 changes: 11 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@

## Get Started

Install the project's dependencies:
### Install the project's dependencies:

```bash
bun install
```

Run the project locally:

### Build the project:
```bash
bun run dev
bun run build
```
Note - if an error comes up involving the [installation of the package sharp](https://github.com/lovell/sharp/issues/3511) while the next-image-export-optimizer is running, you'll need to postinstall sharp:
```bash
cd node_modules/sharp
bun install
```

### Run the project locally:

Build the project:
```bash
bun run build
bun run dev
```

## Local URLs
Expand Down
File renamed without changes.
Binary file modified docs/bun.lockb
Binary file not shown.
17 changes: 16 additions & 1 deletion docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@
const nextConfig = {
output: "export",
images: {
unoptimized: true,
loader: "custom",
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
},
transpilePackages: ["next-image-export-optimizer"],
env: {
nextImageExportOptimizer_imageFolderPath: "public",
nextImageExportOptimizer_exportFolderPath: "out",
nextImageExportOptimizer_quality: 75,
nextImageExportOptimizer_storePicturesInWEBP: true,
nextImageExportOptimizer_exportFolderName: "nextImageExportOptimizer",

// If you do not want to use blurry placeholder images, then you can set
// nextImageExportOptimizer_generateAndUseBlurImages to false and pass
// `placeholder="empty"` to all <ExportedImage> components.
nextImageExportOptimizer_generateAndUseBlurImages: true,
},
};

Expand Down
6 changes: 4 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "bun run build && bun run start",
"build": "next build",
"build": "next build && next-image-export-optimizer",
"start": "http-server ./out",
"lint": "next lint"
},
Expand All @@ -28,6 +28,8 @@
},
"devDependencies": {
"bun-types": "^1.0.1",
"http-server": "^14.1.1"
"http-server": "^14.1.1",
"next-image-export-optimizer": "^1.8.5",
"sharp": "^0.32.6"
}
}
4 changes: 2 additions & 2 deletions docs/src/app/marketingCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Image from "next/image";
import ExportedImage from "next-image-export-optimizer";

type MarketingCardTextProps = {
title: string;
Expand Down Expand Up @@ -37,7 +37,7 @@ export default function MarketingCard({
)}
<div className="md:w-1/2 w-5/6 mb-10 md:mb-0">
<a href={imgURL} target="_blank">
<Image
<ExportedImage
className="object-cover object-center rounded bordered"
alt="hero"
src={imgURL}
Expand Down
6 changes: 3 additions & 3 deletions docs/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Image from "next/image";
import ExportedImage from "next-image-export-optimizer";
import MarketingCard from "./marketingCard";
import Footer from "./footer";

Expand All @@ -7,7 +7,7 @@ export default function Home() {
<main className="flex min-h-screen flex-col items-center">
<nav className="bggrey w-full h-24 p-4 flex justify-center">
<div className="w-full">
<Image
<ExportedImage
src="/sswdory-logo.png"
alt="SSW Dory Logo"
width={300}
Expand All @@ -25,7 +25,7 @@ export default function Home() {
</h1>
</div>
<a href="https://github.com/SSWConsulting/SSW.Dory" target="_blank">
<Image
<ExportedImage
src="/github-mark.svg"
alt="Invertocat Logo"
width={100}
Expand Down

0 comments on commit 8bbd12d

Please sign in to comment.