FatehAK / vite-plugin-image-optimizer

Optimize your image assets using Sharp.js and SVGO.
MIT License
344 stars 15 forks source link

Won't optimize any images in "public" with Remix #44

Open natmfat opened 2 months ago

natmfat commented 2 months ago

Describe the Bug

I'm using Vite with Remix. For some reason, images that are imported in the app directory are optimized, but images in the public directory or not, even when includePublic true.

Steps to reproduce

  1. pnpm create vite & select "Remix"
  2. pnpm add vite-plugin-image-optimizer sharp svgo -D
  3. add ViteImageOptimizer({ includePublic: true }) to vite.config.ts
  4. add some images (or not, Remix comes with a few logos)

Alternatively, clone this repo to reproduce: https://github.com/natmfat/bug-vite-plugin-image-optimizer

> pnpm run build
...
✨ [vite-plugin-image-optimizer] - optimized images successfully:
server/assets/portfolio-home-DOw3Ebwk.png  -73%    cached original: 336.98 kB; cached: 92.32 kB

I expected images in the "public" directory to be transformed as well, not just ones that are imported.

System Info

System:
    OS: macOS 14.6.1
    CPU: (8) arm64 Apple M2
    Memory: 289.22 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.16.0 - ~/.nvm/versions/node/v20.16.0/bin/node
    npm: 10.8.1 - ~/.nvm/versions/node/v20.16.0/bin/npm
    pnpm: 9.6.0 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 129.0.6668.71
    Safari: 17.6
  npmPackages:
    vite: ^5.1.0 => 5.4.8
    vite-plugin-image-optimizer: ^1.1.8 => 1.1.8
    vite-tsconfig-paths: ^4.2.1 => 4.3.2

Used Package Manager

pnpm

Validations

MrVauxs commented 1 week ago

The same happens for SvelteKit (^2.7.3)