Skip to content

Commit a5459bc

Browse files
ungvertgatsbybot
and
gatsbybot
authored
fix(gatsby-transformer-sharp): removed unnecessary conversion to webp (#25325)
* fix(gatsby-transformer-sharp): removed unnecessary conversion to webp * Restore deleted code, which converts to webp with `sharp` and added condition to not convert to webp with `imagemin` second time in Windows. * Deleted everything related to imagemin-webp Co-authored-by: gatsbybot <[email protected]>
1 parent 9042a76 commit a5459bc

File tree

3 files changed

+0
-25
lines changed

3 files changed

+0
-25
lines changed

packages/gatsby-plugin-sharp/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"imagemin": "^6.1.0",
1717
"imagemin-mozjpeg": "^8.0.0",
1818
"imagemin-pngquant": "^6.0.1",
19-
"imagemin-webp": "^5.1.0",
2019
"lodash": "^4.17.15",
2120
"mini-svg-data-uri": "^1.2.3",
2221
"potrace": "^2.1.6",

packages/gatsby-plugin-sharp/src/process-file.js

-20
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const duotone = require(`./duotone`)
66
const imagemin = require(`imagemin`)
77
const imageminMozjpeg = require(`imagemin-mozjpeg`)
88
const imageminPngquant = require(`imagemin-pngquant`)
9-
const imageminWebp = require(`imagemin-webp`)
109
const { healOptions } = require(`./plugin-options`)
1110
const { SharpError } = require(`./sharp-error`)
1211
const { cpuCoreCount, createContentDigest } = require(`gatsby-core-utils`)
@@ -169,11 +168,6 @@ exports.processFile = (file, transforms, options = {}) => {
169168
return transform
170169
}
171170

172-
if (transformArgs.toFormat === `webp`) {
173-
await compressWebP(clonedPipeline, outputPath, transformArgs)
174-
return transform
175-
}
176-
177171
try {
178172
await clonedPipeline.toFile(outputPath)
179173
} catch (err) {
@@ -228,20 +222,6 @@ const compressJpg = (pipeline, outputPath, options) =>
228222
.then(imageminBuffer => fs.writeFile(outputPath, imageminBuffer))
229223
)
230224

231-
const compressWebP = (pipeline, outputPath, options) =>
232-
pipeline.toBuffer().then(sharpBuffer =>
233-
imagemin
234-
.buffer(sharpBuffer, {
235-
plugins: [
236-
imageminWebp({
237-
quality: options.webpQuality || options.quality,
238-
metadata: options.stripMetadata ? `none` : `all`,
239-
}),
240-
],
241-
})
242-
.then(imageminBuffer => fs.writeFile(outputPath, imageminBuffer))
243-
)
244-
245225
exports.createArgsDigest = args => {
246226
const argsDigest = createContentDigest(args)
247227

packages/gatsby/src/schema/__tests__/fixtures/kitchen-sink.json

-4
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,6 @@
380380
"name": "imagemin-pngquant",
381381
"version": "^6.0.0"
382382
},
383-
{
384-
"name": "imagemin-webp",
385-
"version": "^5.0.0"
386-
},
387383
{
388384
"name": "lodash",
389385
"version": "^4.17.10"

0 commit comments

Comments
 (0)