vHeemstra / vite-plugin-imagemin

Vite plugin to compress/minify images with Imagemin
MIT License
19 stars 2 forks source link

make* plugins: inconsistent building #3

Closed NamesMT closed 1 year ago

NamesMT commented 1 year ago

Configs:

viteImagemin({
        plugins: {
          jpg: imageminMozjpeg(),
          png: imageminPngquant(),
        },
        makeWebp: (true || mode === 'webp')
          ? {
              skipIfLargerThan: 'smallest',
              plugins: {
                jpg: imageminWebp({
                  method: 6,
                  quality: 100,
                }),
                png: imageminWebp({
                  method: 6,
                  quality: 100,
                }),
              },
            }
          : undefined,
      }),

Webp randomly doesn't build for some files (Red2.png, Yellow1.png,...)

image

NamesMT commented 1 year ago

Close: Its actually because they're skipped, and echoing at the bottom of the build process:

image

vHeemstra commented 1 year ago

Hi @NamesMT, true. In the latest patch version I tried to move as much of the logs to stay with the general output (see image below).

image

Only the input files that have reading errors or unsupported file formats (Animated PNGs for example) will have their log lines at the end.

This is because of two reasons:

  1. Due to how the process is implemented for speed optimizations. If something goes wrong during reading of the input file, the processing of that file (and any AVIF/WebP output variants) is stopped right then. (We don't have to see the same reading error of a input file for all its output files.)
  2. As these errors should be the exception, having them at the end gives you a quicker overview of these troubled files. And also gives more space to display the errors occurring there (see image below). (Which would otherwise mess up the readability of the logs for all other files.)

image