sindresorhus / gulp-imagemin

Minify PNG, JPEG, GIF and SVG images
MIT License
1.9k stars 157 forks source link

gulp-imagemin plugin crashes with an error. #377

Open hannasorokina opened 1 year ago

hannasorokina commented 1 year ago

I use gulp-imagemin im my gulp as ESM. When I run my gulp task with gulp-imagemin plugin, I've got the issue:

gulp-imagemin: Could not load default plugin `gifsicle`
gulp-imagemin: Could not load default plugin `mozjpeg`
gulp-imagemin: Could not load default plugin `optipng`

image

Windiws 10 x64 Gulp version: "gulp": "^4.0.2"; Plugin version: "gulp-imagemin": "^8.0.0". Node version: v18.12.0.

Does anybody has some solution for the issue?

tomasvn commented 1 year ago

@hannasorokina You have to install those plugins as dev dependency, even though it says in the readme that gulp-imagemin comes bundled with those plugins

Stephan-Pe commented 1 year ago

had the same issue, my solution is: https://github.com/imagemin/imagemin/issues/411

chesio commented 1 year ago

had the same issue, my solution is: imagemin/imagemin#411

@Stephan-Pe Your issue is different - you have to update the configuration of SVGO options. See also: https://github.com/sindresorhus/gulp-imagemin/pull/359

The problem reported by OP (@hannasorokina) can be solved by explicitly importing the plugins:

import imagemin from 'gulp-imagemin';
import { gifsicle, mozjpeg, optipng } from 'gulp-imagemin';

It doesn't seem necessary to install those plugins as dev dependency as @tomasvn suggested (at least I didn't have to do it in my project).