vite-enhancer-config

raw JSON →
1.3.6 verified Mon Apr 27 auth: no javascript

A zero-config plugin that enhances Vite configuration for React applications with production-grade optimizations. Current stable version 1.3.6. Integrates SWC for fast compilation (5-10x faster), automatic Fast Refresh (HMR), and built-in bundle analysis. Ships TypeScript types. Requires Vite v4, v5, or v6 and Node >=18. Differentiator: opinionated, minimal setup with automatic production defaults for React projects.

error Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'vite-enhancer-config' imported from ...
cause Package not installed or not in node_modules.
fix
Run npm install vite-enhancer-config -D.
error TypeError: viteEnhancerConfig is not a function
cause Wrong import style (CommonJS require on ESM-only package).
fix
Use import { viteEnhancerConfig } from 'vite-enhancer-config'.
error Error: Cannot use import statement outside a module
cause Project not configured as ESM (no 'type':'module' in package.json).
fix
Add "type":"module" to package.json or rename file to .mjs.
gotcha Using CommonJS require will fail because the package is ESM-only.
fix Use dynamic import or switch to ESM.
deprecated Option `analyzerKey` was renamed to `apiKey` in v1.3.0.
fix Replace `analyzerKey` with `apiKey` in configuration.
gotcha SWC plugin may conflict with Babel-based React plugins (e.g., @vitejs/plugin-react-swc is not needed).
fix Remove any manual SWC plugin from plugins array when swc option is enabled.
breaking Node 18 minimum required; older versions will throw a syntax error.
fix Upgrade Node.js to v18 or later.
gotcha Bundle analyzer opens a browser on build; may block CI if not configured.
fix Set `analyzer` mode to `static` or disable in non-interactive environments.
npm install vite-enhancer-config
yarn add vite-enhancer-config
pnpm add vite-enhancer-config

Adds SWC compilation and bundle analysis to an existing Vite React setup with typed options.

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { viteEnhancerConfig } from 'vite-enhancer-config';

export default defineConfig({
  plugins: [
    react(),
    viteEnhancerConfig({
      swc: true,
      analyzer: true,
      apiKey: process.env.ANALYZER_KEY ?? ''
    })
  ]
});