Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
jpg: {
quality: 100
},
png: {}
};
optimization = {
webp: webpPlugin({
quality: 100
}),
jpg: mozJpegPlugin({
quality: 100
}),
png: zopfliPlugin(),
gif: gifLossyPlugin(),
svg: svgoPlugin()
};
postfix = (width, mul) => (mul === 1 ? '' : `@${width}w`);
skipOptimization = false;
constructor(config = {}) {
if (typeof config == 'object') {
const { processing, optimization, postfix, skipOptimization } = config;
Object.assign(this.processing, processing);
Object.assign(this.optimization, optimization);
if (typeof postfix == 'function') {
const assets = paths.map(async assetPath => {
const asset = await imagemin([assetPath], '', {
plugins: [
imageminPngquant(options.png),
imageminJpegtran(options.jpg),
imageminGifsicle(options.gif),
imageminSvgo(options.svg)
]
});
asset[0].path = assetPath;
return asset[0];
});
const engineSvg = algorithm => {
switch (algorithm) {
case 'svgo':
return imageminSvgo();
default:
return null;
}
};