routerino 2.5.0 → 2.5.1-rc10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -525,18 +525,21 @@ import { Image } from "routerino/image";
525
525
 
526
526
  ### Image Props
527
527
 
528
- | Prop | Type | Required | Description |
529
- | --------------- | --------------------------- | -------- | ---------------------------------------------------------- |
530
- | `src` | string | ✅ | Image source URL |
531
- | `alt` | string | ✅ | Alt text for accessibility |
532
- | `priority` | boolean | ❌ | Override lazy loading for hero/LCP images |
533
- | `widths` | number[] | ❌ | Custom responsive widths (default: [480, 800, 1200, 1920]) |
534
- | `sizes` | string | ❌ | Responsive sizes attribute (has smart default) |
535
- | `className` | string | ❌ | CSS classes (Tailwind/DaisyUI ready) |
536
- | `style` | object | ❌ | Inline styles |
537
- | `loading` | "lazy" \| "eager" | ❌ | Loading behavior (auto-set based on priority) |
538
- | `decoding` | "sync" \| "async" \| "auto" | ❌ | Decode timing (default: "async") |
539
- | `fetchpriority` | "high" \| "low" \| "auto" | ❌ | Fetch priority (auto-set based on priority) |
528
+ | Prop | Type | Required | Description |
529
+ | --------------- | --------------------------- | -------- | ---------------------------------------------------------------- |
530
+ | `src` | string | ✅ | Image source URL (supports jpg, png, webp, avif, gif, bmp, tiff) |
531
+ | `alt` | string | ✅ | Alt text for accessibility |
532
+ | `priority` | boolean | ❌ | Override lazy loading for hero/LCP images |
533
+ | `widths` | number[] | ❌ | Custom responsive widths (default: [480, 800, 1200, 1920]) |
534
+ | `sizes` | string | ❌ | Responsive sizes attribute (has smart default) |
535
+ | `className` | string | ❌ | CSS classes (Tailwind/DaisyUI ready) |
536
+ | `style` | object | ❌ | Inline styles |
537
+ | `width` | number | ❌ | Explicit width attribute (CLS prevention) |
538
+ | `height` | number | ❌ | Explicit height attribute (CLS prevention) |
539
+ | `loading` | "lazy" \| "eager" | ❌ | Loading behavior (auto-set based on priority) |
540
+ | `decoding` | "sync" \| "async" \| "auto" | ❌ | Decode timing (default: "async") |
541
+ | `fetchpriority` | "high" \| "low" \| "auto" | ❌ | Fetch priority (auto-set based on priority) |
542
+ | `ref` | React.Ref | ❌ | Forwarded to the underlying `<img>` element |
540
543
 
541
544
  ### Image Usage Examples
542
545
 
@@ -926,7 +929,7 @@ export default defineConfig({
926
929
  // useTrailingSlash: true, // Set to false for /about instead of /about/
927
930
  // verbose: false,
928
931
  // ssgCacheDir: "node_modules/.cache/routerino-forge", // SSG cache directory
929
- // optimizeImages: true, // Enable image optimization (see below)
932
+ // imageOptions: {}, // Customize image optimization (see Image Optimization below)
930
933
  }),
931
934
  ],
932
935
  });
@@ -955,38 +958,42 @@ export default defineConfig({
955
958
  - Creates a 404.html page
956
959
  - Skips dynamic routes (with `:param` syntax)
957
960
  - SEO optimized: Complete HTML with meta tags
958
- - Image optimization: Automatic blur placeholders (LQIP)
961
+ - Image optimization: Automatic responsive variants + blur placeholders (LQIP)
959
962
  - Easy configuration: Works out of the box with Vite and minimal setup
960
963
 
961
964
  #### Image Optimization
962
965
 
963
- Routerino Forge can automatically optimize images in your static builds for faster loading:
966
+ Routerino Forge automatically processes `<Image>` components during the build to generate responsive image variants and LQIP (Low Quality Image Placeholder) blur-up effects. Image optimization is always enabled when ffmpeg is available — no flag needed to turn it on. Use `imageOptions` to customize:
964
967
 
965
968
  ```js
966
969
  routerinoForge({
967
- optimizeImages: true, // Enable with defaults
968
- // Or configure in detail:
969
- optimizeImages: {
970
- enabled: true,
971
- placeholderSize: 20, // Size of blur placeholder (20x20 pixels)
972
- blur: 4, // Blur radius for placeholder
973
- maxSize: 10485760, // Maximum image size to process (10MB)
974
- minSize: 1024, // Minimum image size to process (1KB)
975
- cacheDir: "node_modules/.cache/routerino-forge", // Cache directory
970
+ baseUrl: "https://example.com",
971
+ imageOptions: {
972
+ widths: [480, 800, 1200, 1920], // Responsive widths to generate
973
+ formats: ["webp"], // Extra formats (webp is always generated)
974
+ placeholderSize: 20, // Height of LQIP placeholder in px
975
+ blur: 4, // Blur radius for LQIP placeholder
976
+ maxSize: 10485760, // Max source image size to process (10MB)
977
+ minSize: 1024, // Min source image size to process (1KB)
978
+ cacheDir: "node_modules/.cache/routerino-forge",
976
979
  },
977
980
  });
978
981
  ```
979
982
 
983
+ All keys in `imageOptions` are optional — omit any to keep the default.
984
+
980
985
  **What it does:**
981
986
 
982
- - Generates tiny blur placeholders for images (base64 encoded)
983
- - Caches processed images to speed up subsequent builds
984
- - Preserves original images while enhancing loading performance
985
- - Skips external images (http/https), data URIs, and SVGs
986
- - Smart sizing: Uses aspect-ratio only to prevent layout shift without forcing dimensions
987
- - Hides images initially with `opacity: 0` to prevent broken image icons during load
987
+ - Generates responsive image variants at each configured width (WebP + original format)
988
+ - Generates LQIP blur placeholders (tiny base64 PNG shown while image loads)
989
+ - Anti-upscaling: never generates variants wider than the source image
990
+ - Caches generated variants to speed up subsequent builds
991
+ - Skips external URLs (http/https), data URIs, and SVGs
992
+ - Skips images below `minSize` or above `maxSize`
993
+ - Adds `width`/`height` attributes to `<img>` tags for CLS prevention
994
+ - Stale cache entries are automatically cleaned up (50 most recent kept)
988
995
 
989
- **Note:** Image optimization requires `ffmpeg` to be installed on your system. Install with `brew install ffmpeg` (Mac), `apt install ffmpeg` (Debian/Ubuntu), or `choco install ffmpeg` (Windows). Without ffmpeg, the Image component still works but falls back to the original image without optimization. A warning is shown during build if ffmpeg is not found but Image components are used.
996
+ **Note:** Image optimization requires `ffmpeg` to be installed on your system. Install with `brew install ffmpeg` (Mac), `apt install ffmpeg` (Debian/Ubuntu), or `choco install ffmpeg` (Windows). Without ffmpeg, the Image component still works but falls back to the original image without responsive variants or LQIP. A warning is shown during build if ffmpeg is not found but Image components are used.
990
997
 
991
998
  ##### CI/CD Setup for Image Optimization
992
999
 
@@ -1069,6 +1076,35 @@ In your netlify.toml:
1069
1076
  publish = "dist"
1070
1077
  ```
1071
1078
 
1079
+ ###### Cloudflare Pages
1080
+
1081
+ Cloudflare Pages doesn't allow `apt-get`. Use the `ffmpeg-static` / `ffprobe-static` npm packages instead.
1082
+
1083
+ In the **Cloudflare Pages dashboard** under **Settings > Build & Deployments > Build command**:
1084
+
1085
+ ```
1086
+ npm ci && npm install --no-save ffmpeg-static ffprobe-static && ln -sf "$(node -e "console.log(require('ffmpeg-static'))")" /tmp/ffmpeg && ln -sf "$(node -e "console.log(require('ffprobe-static').path)")" /tmp/ffprobe && export PATH="/tmp:$PATH" && npm run build
1087
+ ```
1088
+
1089
+ Or in your `wrangler.toml`:
1090
+
1091
+ ```toml
1092
+ [build]
1093
+ command = """
1094
+ npm ci && \
1095
+ npm install --no-save ffmpeg-static ffprobe-static && \
1096
+ ln -sf "$(node -e "console.log(require('ffmpeg-static'))")" /tmp/ffmpeg && \
1097
+ ln -sf "$(node -e "console.log(require('ffprobe-static').path)")" /tmp/ffprobe && \
1098
+ export PATH="/tmp:$PATH" && \
1099
+ npm run build
1100
+ """
1101
+
1102
+ [build.environment]
1103
+ NODE_VERSION = "20"
1104
+ ```
1105
+
1106
+ > **Note:** Without ffmpeg, the SSG still builds successfully — the forge plugin automatically strips responsive image references so browsers load the original images without 404s. Install ffmpeg to enable WebP variants, LQIP blur placeholders, and responsive image sets for better Lighthouse scores.
1107
+
1072
1108
  #### Routes Configuration
1073
1109
 
1074
1110
  **Critical for SSG**: Routes MUST be exported for the build plugin to discover them. The plugin needs to import your routes at build time, so inline route definitions won't work.