Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new option to print out data saving information #96

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix code issues after merge
HappyTobi committed Oct 21, 2019
commit 8d8f253d7f36b090784ca9421b18e6041085fe6f
2 changes: 1 addition & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ export async function optimizeImage (imageData, fileName, { imageminOptions, onl

// Await for imagemin to do the compression
const optimizedImageBuffer = await imagemin.buffer(imageBuffer, imageminOptions)
if (sizeInfoLog) {
if (sizeInfo) {
const optimizedSize = optimizedImageBuffer.length
const savedBytes = originalSize - optimizedSize
var savedPercentage = 0
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ export default class ImageminPlugin {
pngquant = null,
externalImages = {},
cacheFolder = null,
sizeInfo = false
sizeInfo = false,
onlyUseIfSmaller = false
} = options

@@ -179,7 +179,7 @@ export default class ImageminPlugin {
// Use the helper function to get the file from cache if possible, or
// run the optimize function and store it in the cache when done
let optimizedImageBuffer = await getFromCacheIfPossible(cacheFolder, fileData, async () => {
return optimizeImage(fileData, path.basename(filename), this.options)
return optimizeImage(fileData, path.basename(filename), this.options)
})

if (fileName) {