Registry / devops / vite-plugin-package-config

vite-plugin-package-config

JSON →
library0.1.1jsnpmunverified

A Vite plugin (v0.1.1, latest) that allows extending Vite configuration via a `vite` field in package.json. Developed by Anthony Fu, it provides a declarative, JSON-based alternative to vite.config.ts for static config like resolve aliases and build output, making it easier to share and manipulate config across tools. It requires Vite ^2.0.0, ships TypeScript types, and has a minimal API — just one function call.

npm install vite-plugin-package-config
INSTALL
IMPORT
SIG · VITE-PLUGIN-PACKAG
V
vite-plugin-package-config
devopsjavascriptv0.1.1
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.

PkgConfig
import PkgConfig from 'vite-plugin-package-config'
const PkgConfig = require('vite-plugin-package-config')
Default ESM import is the intended usage. CJS require() may work but is not recommended and not tested.
default
import PkgConfig from 'vite-plugin-package-config'
import { PkgConfig } from 'vite-plugin-package-config'
The package exports a single function as default. Named import will result in undefined.
type definitions
import type { Plugin } from 'vite'; import PkgConfig from 'vite-plugin-package-config'
import { VitePluginPackageConfig } from 'vite-plugin-package-config'
The package does not export a named type. Use Vite's Plugin type directly.

Shows how to install and use the plugin to extend Vite config from package.json's 'vite' field.

// vite.config.ts import PkgConfig from 'vite-plugin-package-config'; import { defineConfig } from 'vite'; export default defineConfig({ plugins: [ PkgConfig() ] }); // package.json { "name": "my-app", "version": "1.0.0", "vite": { "resolve": { "alias": { "@": "/src" } }, "build": { "outDir": "dist" } } }
Debug
Known issues
gotchaOnly static config that can be JSON-serialized is supported. Functions, objects with circular references, or dynamic values cannot be placed in package.json.
fix
Use vite.config.ts for dynamic configurations.
affects: *
gotchaThe plugin merges config from package.json with vite.config.ts; duplicate config fields may cause unexpected behavior depending on merge order.
fix
Explicitly set precedence by ordering plugins or using the 'enforce' property.
affects: *
deprecatedThe 'output' alias field (e.g., 'build.output') is deprecated in Vite; use 'outDir' instead.
fix
Use Vite's official config fields like 'outDir' instead of 'output'.
affects: >=0.1.0
gotchaThe plugin reads package.json from the project root; if the root is not correctly configured, it may fail silently.
fix
Ensure process.cwd() matches the directory containing package.json, or set root in Vite config.
affects: *
Errors
Common errors & fixes
Cannot find module 'vite-plugin-package-config'
Package not installed or missing from node_modules.
fix
Run 'npm install -D vite-plugin-package-config'.
TypeError: PkgConfig is not a function
Named import used instead of default import.
fix
Use 'import PkgConfig from "vite-plugin-package-config"'.
Invalid config: field 'vite' in package.json is not recognized
The custom 'vite' field is not part of Vite's official schema but is read by the plugin.
fix
Ignore the warning; the plugin parses it correctly.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
viterequiredPeer dependency; plugin only works with Vite's plugin system.
Agent activity
24 hits · last 30 days
node
18
OpenAI (training)
1
Resources
vite-plugin-package-config — npm install vite-plugin-package-config · libregistry