Vite · VITE0026

Return only new array entries from Vite config hooks

Reports Vite config and configEnvironment hooks that return arrays containing the incoming config's entries.
VITE0026vite-doctor/vitepluginswarnNo fix

Run this rule

pnpm vite-doctor . --framework vite --rules vite/plugin/no-config-hook-array-echo

Why it matters

Vite merges each config and configEnvironment hook result into the current config with mergeConfig, which concatenates arrays instead of replacing them. A hook that returns ...config.ssr.noExternal, 'my-package' therefore adds every existing entry a second time, and each plugin that does this doubles the entries of the plugins before it. Doctor reports a returned array at a config path that spreads or concatenates the incoming value at the same path, directly or through a helper function defined once in the same file that returns its parameter spread or concatenated. It does not follow helpers imported from other files, and it ignores hooks that assign to the incoming config in place. An object counts as a plugin when it has Vite plugin hooks such as configResolved or enforce, or when it has a name and the file imports or requires Vite, Vitest, Rollup, Rolldown, unplugin, or @nuxt/kit, or is a Vite config.

Return only the entries the plugin adds, skipping entries that are already present, or assign to the incoming config in place and leave that field out of the returned object.

Example

Return only the added entries

Before

export function dedupePlugin(): Plugin {
  return {
    name: 'dedupe-vue',
    config(config) {
      return {
        resolve: { dedupe: [...(config.resolve?.dedupe ?? []), 'vue'] },
      }
    },
  }
}

After

export function dedupePlugin(): Plugin {
  return {
    name: 'dedupe-vue',
    config(config) {
      if (config.resolve?.dedupe?.includes('vue')) return
      return { resolve: { dedupe: ['vue'] } }
    },
  }
}
Copyright © 2026