metalsmith-optimize-images 0.10.0 → 0.10.2

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
@@ -199,6 +199,32 @@ Add the `data-no-responsive` attribute to any image you don't want processed:
199
199
  <img src="image.jpg" data-no-responsive alt="This image won't be processed" />
200
200
  ```
201
201
 
202
+ ## Supported File Types
203
+
204
+ The plugin automatically processes raster images and skips vector graphics:
205
+
206
+ ### ✅ Processed
207
+ - **JPEG** (`.jpg`, `.jpeg`)
208
+ - **PNG** (`.png`)
209
+ - **GIF** (`.gif`)
210
+ - **WebP** (`.webp`)
211
+ - **AVIF** (`.avif`)
212
+
213
+ ### ❌ Automatically Skipped
214
+ - **SVG** (`.svg`) - Vector graphics don't need responsive raster variants
215
+ - **External URLs** (http/https)
216
+ - **Data URLs** (`data:image/...`)
217
+ - **Images with `data-no-responsive` attribute**
218
+
219
+ ### Why SVGs are skipped
220
+
221
+ SVG files are vector graphics that scale perfectly at any resolution without quality loss. Creating multiple raster sizes and formats from SVGs would:
222
+ - Increase build time unnecessarily
223
+ - Generate larger file sizes than the original vector
224
+ - Lose the scalability benefits of SVG format
225
+
226
+ If you have SVG logos or icons, they will remain untouched and work perfectly as-is.
227
+
202
228
  ## Background Images
203
229
 
204
230
  The plugin automatically processes images that aren't referenced in HTML for use as CSS background images. This feature is enabled by default (`processUnusedImages: true`).
package/lib/index.cjs CHANGED
@@ -343,6 +343,12 @@ async function processImage({
343
343
  return;
344
344
  }
345
345
 
346
+ // Skip SVG files - they are vector graphics that don't need responsive raster variants
347
+ if (src.toLowerCase().endsWith('.svg')) {
348
+ debug(`Skipping SVG file (vector graphics don't need responsive variants): ${src}`);
349
+ return;
350
+ }
351
+
346
352
  // Normalize src path to match Metalsmith files object keys
347
353
  // Remove leading slash if present (HTML paths vs Metalsmith file keys)
348
354
  const normalizedSrc = src.startsWith('/') ? src.slice(1) : src;
@@ -999,6 +1005,12 @@ async function processProgressiveImage({
999
1005
  return;
1000
1006
  }
1001
1007
 
1008
+ // Skip SVG files - they are vector graphics that don't need responsive raster variants
1009
+ if (src.toLowerCase().endsWith('.svg')) {
1010
+ debug(`Skipping SVG file (vector graphics don't need responsive variants): ${src}`);
1011
+ return;
1012
+ }
1013
+
1002
1014
  // Normalize src path to match Metalsmith files object keys
1003
1015
  const normalizedSrc = src.startsWith('/') ? src.slice(1) : src;
1004
1016