Skip to content

Commit

Permalink
fix: compress plugin not outputting original image (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zyie authored Sep 3, 2024
1 parent f4907af commit 718b55c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/assetpack/src/image/compress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ export function compress(options: CompressOptions = {}): AssetPipe<CompressOptio
return newAsset;
});

// ensure that the original image is passed through if it is not compressed by png/jpg options
if ((image.format === '.png' && !options.png) || (((image.format === '.jpg') || (image.format === '.jpeg')) && !options.jpg))
{
newAssets.push(asset);
}

const promises = processedImages.map((image, i) => image.sharpImage.toBuffer().then((buffer) =>
{
newAssets[i].buffer = buffer;
Expand Down
4 changes: 2 additions & 2 deletions packages/assetpack/test/image/Compress.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ describe('Compress', () =>
cache: false,
pipes: [
compress({
png: true,
png: false,
webp: true,
jpg: true,
jpg: false,
avif: true,
}),
],
Expand Down

0 comments on commit 718b55c

Please sign in to comment.