Skip to content

@wxt-dev/auto-icons generates duplicate icons when custom sizes overlap defaults #2491

Description

@zryyyy

Describe the bug

@wxt-dev/auto-icons intentionally merges custom icon sizes with its default sizes, but it does not deduplicate the resulting array.

For example, with:

autoIcons: {
  baseIconPath: 'assets/icon.svg',
  sizes: [16, 32, 48, 96, 128],
  developmentIndicator: false,
},

the configured sizes are concatenated with the defaults [128, 48, 32, 16], resulting in an effective array equivalent to:

[16, 32, 48, 96, 128, 128, 48, 32, 16]

The overlapping sizes are then processed twice by Sharp and written to the same output paths twice.

The build summary shows:

.output/chrome-mv3-dev/icons/128.png
.output/chrome-mv3-dev/icons/128.png
.output/chrome-mv3-dev/icons/16.png
.output/chrome-mv3-dev/icons/16.png
.output/chrome-mv3-dev/icons/32.png
.output/chrome-mv3-dev/icons/32.png
.output/chrome-mv3-dev/icons/48.png
.output/chrome-mv3-dev/icons/48.png
.output/chrome-mv3-dev/icons/96.png

I understand that merging custom sizes with the default sizes is intentional. However, duplicate sizes should be removed before generating icons.

For the configuration above, each of 16, 32, 48, 96, and 128 should only be generated once.

A possible fix would be to deduplicate the resolved sizes:

const sizes = [...new Set(parsedOptions.sizes)];

and use sizes in the manifest, icon generation, and public-path hooks.

Reproduction

A minimal reproduction project.tar.gz is attached to this issue.

Steps to reproduce

  1. Install the dependencies:
npm install
  1. Use the following wxt.config.ts configuration:
import { defineConfig } from 'wxt';

export default defineConfig({
  modules: [
    '@wxt-dev/module-react',
    '@wxt-dev/auto-icons',
  ],
  autoIcons: {
    baseIconPath: 'assets/icon.svg',
    sizes: [16, 32, 48, 96, 128],
    developmentIndicator: false,
  },
});
  1. Start the development build:
npm run dev
  1. Check the build summary.

The entries for 16.png, 32.png, 48.png, and 128.png are each listed twice, while 96.png is listed once.

Removing the default sizes from the custom array and using only:

sizes: [96]

avoids the duplicate processing because the default sizes are appended automatically.

System Info

npx envinfo --system --browsers --binaries --npmPackages @wxt-dev/auto-icons,wxt,vite

  System:
    OS: Windows 11 10.0.26200
    CPU: (16) x64 AMD Ryzen 7 4800H with Radeon Graphics         
    Memory: 10.61 GB / 31.37 GB
  Binaries:
    Node: 24.18.0 - C:\Users\Matrix\AppData\Local\fnm_multishells\28944_1783789127586\node.EXE
    npm: 11.16.0 - C:\Users\Matrix\AppData\Local\fnm_multishells\28944_1783789127586\npm.CMD
    pnpm: 11.9.0 - C:\Users\Matrix\AppData\Local\pnpm\bin\pnpm.CMD
  Browsers:
    Chrome: 150.0.7871.114
    Edge: Chromium (149.0.4022.98)
  npmPackages:
    @wxt-dev/auto-icons: ^1.1.1 => 1.1.1 
    wxt: ^0.20.27 => 0.20.27

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending-triageSomeone (usually a maintainer) needs to look into this to see if it's a bug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions