Skip to content

Commit

Permalink
Merge branch 'main' into feat/data-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Zyie authored Sep 3, 2024
2 parents 90ffd66 + 972ce84 commit 05d818b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function convertName(pth: string, nameStyle: 'short' | 'relative', removeFileExt
{
const name = nameStyle === 'short' ? path.basename(pth) : pth;

return removeFileExtension ? path.parse(name).name : name;
return removeFileExtension ? path.trimExt(name) : name;
}

export function createJsons(
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
2 changes: 1 addition & 1 deletion packages/docs/docs/guide/pipes/texture-packer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ To compress the texture atlases you can use the `texturePackerCompress` plugin.

```js
import { compress } from "@assetpack/core/image";
import { compress } from "@assetpack/core/texture-packer";
import { texturePackerCompress } from "@assetpack/core/texture-packer";

// these options are the default values, all options shown here are optional
const options = {
Expand Down

0 comments on commit 05d818b

Please sign in to comment.