Klathmon / imagemin-webpack-plugin

Plugin to compress images with imagemin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add option `progress`

alexander-akait opened this issue · comments

When you have many files, we have to wait a long time and it is not clear how many have tightened as there is, it would be very convenient to see the progress.

Maybe use https://github.com/sindresorhus/ora for logging filenames and count images are compressed and not.

P.S.: sorry that did not have time to write tests as promised, very little time for the new year 😭

I'd prefer to not output anything myself in this library as that's more of the job of webpack itself (with it's progress settings/flags, and in some cases dedicated progress plugins).

If there is a way to hook into webpack to report that some progress is being made I'd rather do it that way as it would be more "correct". I'll need to look into this, as with webpack 2 things are changing a lot in that world.

And don't worry about not writing tests, you don't owe me or anyone else anything! I'm swamped with stuff as well, so it's no big deal.

@Klathmon Unfortunately webpack can only output assets and progress for own event. He can not know what progress is now inside the plugin, and I think that it will never be implemented in webpack. It is therefore logical to assume that it rests on the plugin developers. Today I build the project in which it was about 10k images (3 mb minimum image size) and I was in a deep misunderstanding of what is happening.

Fair enough!

I've admittedly opened my OS's system monitor to see the number of imagemin processes running to see if it's working correctly, so something here would be useful.

I'll look into adding it to the plugin.

Do you know offhand if it's possible to check on if the "progress" flag is set in webpack? And if it is would you have any objections to using that instead of a special config for this plugin?

@Klathmon sgtm for getting progress from webpack. Unfortunately I do not have webpack near, maybe compiler contain global webpack options.

This would be super useful, IMO. I'm writing a React starter kit that I'd like to use this library for, and I think users will start to get concerned with build times that seemingly 'stall' for a few minutes due to volume of files.

Especially pngs -- they can take an age to process.

Appreciate your time on this @Klathmon - very useful plugin!

@leebenson Thanks, but I'm not sure how feasible this change is going to be.

Webpack handles all the output for the progress flag, so I'm not going to be able to put out my own unless I require that webpack's progress flag not be used (which I really don't want to do).

So unless there is some way for me to report progress back to webpack, this isn't going to be implemented most likely.

That being said, I might be making some fairly large changes to this library so that it runs much sooner in the process, and a side-effect of that is that most images might be optimized before they hit the loaders, so every time one is completed it should show some progress through webpack.

Only images which aren't required will be done at the end, so it should lessen the impact of not having any kind of progress indicator.

Thanks @Klathmon. I'm not familiar with the API that Webpack exposes, so what I'm suggesting certainly may not be possible.

Your upcoming changes sound good though- will definitely look out for those.

Thanks!

I'm going to close this now. If anyone has any ideas on how to implement it feel free to open it and comment, but until then I can't figure any good way to introduce a progress system without "taking over" the whole console.

After having this plugin grow bigger than I previously thought it would (both in complexity and usage), I decided to reopen this issue and see if I can add an optional showProgress option.

Any updates on this? :)