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

Does not appear to work with Gulp v4.0.2 #371

Open
cyberjetx opened this issue Apr 15, 2022 · 0 comments
Open

Does not appear to work with Gulp v4.0.2 #371

cyberjetx opened this issue Apr 15, 2022 · 0 comments

Comments

@cyberjetx
Copy link

cyberjetx commented Apr 15, 2022

Since moving to gulp v4 I have not been able to use imagemin.

environment: windows cmd
gulp -v CLI version: 2.3.0 & Local version: 4.0.2

The closest I have gotten is this:
...
let /** @type {import("gulp-imagemin")} / imagemin;
let /
* @type {import("imagemin-jpegtran")} / imageminJpegtran;
let /
* @type {import("imagemin-pngquant").default} */ imageminPngquant;

const startup = async () => {
// @ts-ignore
imagemin = (await import("gulp-imagemin")).default;
// @ts-ignore
imageminJpegtran = (await import("imagemin-jpegtran")).default;
imageminPngquant = (await import("imagemin-pngquant")).default;
};

// run this task before any that require imagemin
gulp.task("startup", async () => {
await startup();
});
gulp.task('imageminx', function(done) {
startup;
return gulp.src('./src/images/.')
.pipe(imagemin())
.pipe(gulp.dest('./dist/images/'));
});
...

which, sadly, still reports error:
C:\Source\gulptests>gulp imageminx
[15:41:22] Using gulpfile C:\Source\gulptests\gulpfile.js
[15:41:22] Starting 'imageminx'...
[15:41:22] 'imageminx' errored after 13 ms
[15:41:22] TypeError: imagemin is not a function
at \Mac\Home\Documents\Source\gulptests\gulpfile.js:44:11
at taskWrapper (\Mac\Home\Documents\Source\gulptests\node_modules\undertaker\lib\set-task.js:13:15)
at bound (node:domain:421:15)
at runBound (node:domain:432:12)
at asyncRunner (\Mac\Home\Documents\Source\gulptests\node_modules\async-done\index.js:55:18)
at processTicksAndRejections (node:internal/process/task_queues:78:11)

If I am missing something I apologize for the ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant