diff --git a/packages/json/src/index.ts b/packages/json/src/index.ts index 102b882..50ea00e 100644 --- a/packages/json/src/index.ts +++ b/packages/json/src/index.ts @@ -25,10 +25,7 @@ export function json(_options: JsonOptions = {}): AssetPipe { try { - let json = JSON.parse(asset.buffer.toString()); - - json = JSON.stringify(json); - + const json = JSON.parse(asset.buffer.toString()); const compressedJsonAsset = createNewAssetAt(asset, asset.filename); compressedJsonAsset.buffer = Buffer.from(JSON.stringify(json, null, 2)); diff --git a/packages/mipmap-compress/src/mipmapCompress.ts b/packages/mipmap-compress/src/mipmapCompress.ts index 752bb2a..1355d4c 100644 --- a/packages/mipmap-compress/src/mipmapCompress.ts +++ b/packages/mipmap-compress/src/mipmapCompress.ts @@ -44,17 +44,13 @@ export interface MipmapCompressImageData const defaultMipmapOptions: Required = { template: '@%%x', - resolutions: { default: 1 }, + resolutions: { default: 1, low: 0.5 }, fixedResolution: 'default' }; export function mipmapCompress(_options: MipmapCompressOptions = {}): AssetPipe { - const mipmap = resolveOptions(_options.mipmap, { - template: '@%%x', - resolutions: { default: 1, low: 0.5 }, - fixedResolution: 'default' - }); + const mipmap = resolveOptions(_options.mipmap, defaultMipmapOptions); const compress = resolveOptions(_options.compress, { png: true, @@ -91,7 +87,7 @@ export function mipmapCompress(_options: MipmapCompressOptions = {}): AssetPipe< return { folder: true, - name: 'mipmap-compress', + name: 'mip-compress', defaultOptions, test(asset: Asset, options) { @@ -99,9 +95,8 @@ export function mipmapCompress(_options: MipmapCompressOptions = {}): AssetPipe< }, async transform(asset: Asset, options) { - const mip = options.mipmap && !asset.metaData[options.tags.fix as any]; - - const compress = options.compress && !asset.metaData[options.tags.nc as any]; + const shouldMipmap = mipmap && !asset.metaData[options.tags.fix as any]; + const shouldCompress = compress && !asset.metaData[options.tags.nc as any]; let processedImages: MipmapCompressImageData[]; @@ -114,10 +109,10 @@ export function mipmapCompress(_options: MipmapCompressOptions = {}): AssetPipe< // first mipmap if we want.. try { - if (mip) + if (shouldMipmap) { const { resolutions, fixedResolution } = options.mipmap as Required - || defaultMipmapOptions; + || defaultOptions.mipmap; const fixedResolutions: {[x: string]: number} = {}; @@ -131,7 +126,7 @@ export function mipmapCompress(_options: MipmapCompressOptions = {}): AssetPipe< image.resolution = largestResolution; - processedImages = mip ? await mipmapSharp(image, resolutionHash, largestResolution) : [image]; + processedImages = shouldMipmap ? await mipmapSharp(image, resolutionHash, largestResolution) : [image]; } else { @@ -145,7 +140,7 @@ export function mipmapCompress(_options: MipmapCompressOptions = {}): AssetPipe< try { - if (compress) + if (shouldCompress) { processedImages = (await Promise.all( processedImages.map((image) => compressSharp(image, options.compress as CompressOptions))