Registry / web-framework / vite-config-react

vite-config-react

JSON →
library1.2.8jsnpmunverified

vite-config-react is a lightweight, modular Vite configuration generator for React projects. Current version 1.2.8 requires Node.js >=18 and Vite 5+. It provides a clean API to generate Vite configs with presets for React, plugins, and features. Unlike manually writing vite.config.ts, it offers a declarative, composable approach with built-in React support, TypeScript types, and extensibility through plugins. Updated regularly with minor releases every few months. Focuses on developer experience and zero-config setup while remaining fully customizable.

npm install vite-config-react
INSTALL
IMPORT
SIG · VITE-CONFIG-REACT
V
vite-config-react
web-frameworkjavascriptv1.2.8
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

defineConfig
import { defineConfig } from 'vite-config-react'
import defineConfig from 'vite-config-react'
Named export, not default. ESM only – CJS require is not supported.
reactPreset
import { reactPreset } from 'vite-config-react'
import { react } from 'vite-config-react'
Named export. The preset is called 'reactPreset', not 'react'.
Plugin
import type { Plugin } from 'vite-config-react'
import { Plugin } from 'vite-config-react'
Plugin is a TypeScript type; import with `type` to avoid runtime issues.

Generates a basic Vite config with React preset, custom server port, and sourcemaps enabled in build.

import { defineConfig, reactPreset } from 'vite-config-react'; export default defineConfig({ presets: [reactPreset()], server: { port: 3000, }, build: { sourcemap: true, }, });
Debug
Known issues
breakingConfig format changed in v1.0.0: presets are now an array instead of single object.
fix
Pass presets as an array: presets: [reactPreset()].
affects: <1.0.0
breakingNode.js >=18 required starting from v1.2.0.
fix
Upgrade Node.js to version 18 or higher.
affects: <1.2.0
deprecatedThe 'include' option in reactPreset is deprecated; use 'features.include' instead.
fix
Replace reactPreset({ include: '...' }) with reactPreset({ features: { include: '...' } }).
affects: >=1.2.0
gotchaRequires Vite 5+; using with Vite 4 may cause runtime errors.
fix
Ensure Vite version is 5 or higher.
affects: >=1.0.0
gotchaCommonJS (require) is not supported; only ESM imports work.
fix
Use import syntax. If using CJS project, use dynamic import().
affects: >=1.0.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Project is set to CommonJS (type: 'commonjs' in package.json) but uses ESM import.
fix
Set { "type": "module" } in package.json or rename file to .mjs and use Node --experimental-modules flag (deprecated).
TypeError: (0 , _viteConfigReact.defineConfig) is not a function
Default import used instead of named import: import defineConfig from 'vite-config-react'
fix
Change to import { defineConfig } from 'vite-config-react'
Error: reactPreset is not a function
Misspelled or wrong import: import { react } from 'vite-config-react'
fix
Use correct import: import { reactPreset } from 'vite-config-react'
Unknown option: presets. Did you mean 'plugins'?
Config mismatch when using vite-config-react with older Vite version (<5) or misusing another config tool.
fix
Ensure Vite version >=5 and using vite-config-react exports correctly.
Upgrade
Version history
1.2.8latest on npm
Audit
Dependencies
viterequiredPeer dependency; required to use the generated config.
@vitejs/plugin-reactoptionalPackage includes React preset that depends on this plugin.
Agent activity
2 hits · last 30 days
node
2
Resources
vite-config-react — npm install vite-config-react · libregistry