Check if sharp is failing on bundle before running image minimizer
parent
1316a3d7d8
commit
86c2769221
|
|
@ -28,8 +28,10 @@ const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
|
||||||
|
|
||||||
let isSharpAvailable = true;
|
let isSharpAvailable = true;
|
||||||
try {
|
try {
|
||||||
require.resolve('sharp');
|
const sharp = require('sharp');
|
||||||
} catch (e) {
|
// It is possible that sharp is installed but fails on running
|
||||||
|
sharp();
|
||||||
|
} catch {
|
||||||
isSharpAvailable = false;
|
isSharpAvailable = false;
|
||||||
console.warn('Sharp is not available, image optimization will be disabled.');
|
console.warn('Sharp is not available, image optimization will be disabled.');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue