Vite · Configuration

VITE0004Avoid object values in Vite define

Flags runtime object define in Vite define code before it leaks into runtime behavior.

Why it happens

Runtime configuration has different server and client visibility. Using the framework API keeps environment data typed and scoped.

Fix

Remove runtime object define, or move it to the Vite runtime/API that owns that behavior.

Example

Avoid runtime object define

Before

export default defineConfig({
  define: {
    __APP_CONFIG__: { feature: true },
  },
})

After

export default defineConfig({
  define: {
    __FEATURE_ENABLED__: JSON.stringify(true),
  },
})

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm vite-doctor . --framework vite --extends auto,vite/strict --rules vite/define/no-runtime-object-define
Copyright © 2026