{"id":22772,"library":"vite-plugin-package-config","title":"Vite Plugin Package Config","description":"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.","status":"active","version":"0.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/antfu/vite-plugin-package-config","tags":["javascript","vite-plugin","typescript"],"install":[{"cmd":"npm install vite-plugin-package-config","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-package-config","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-package-config","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin only works with Vite's plugin system.","package":"vite","optional":false}],"imports":[{"note":"Default ESM import is the intended usage. CJS require() may work but is not recommended and not tested.","wrong":"const PkgConfig = require('vite-plugin-package-config')","symbol":"PkgConfig","correct":"import PkgConfig from 'vite-plugin-package-config'"},{"note":"The package exports a single function as default. Named import will result in undefined.","wrong":"import { PkgConfig } from 'vite-plugin-package-config'","symbol":"default","correct":"import PkgConfig from 'vite-plugin-package-config'"},{"note":"The package does not export a named type. Use Vite's Plugin type directly.","wrong":"import { VitePluginPackageConfig } from 'vite-plugin-package-config'","symbol":"type definitions","correct":"import type { Plugin } from 'vite'; import PkgConfig from 'vite-plugin-package-config'"}],"quickstart":{"code":"// vite.config.ts\nimport PkgConfig from 'vite-plugin-package-config';\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n  plugins: [\n    PkgConfig()\n  ]\n});\n\n// package.json\n{\n  \"name\": \"my-app\",\n  \"version\": \"1.0.0\",\n  \"vite\": {\n    \"resolve\": {\n      \"alias\": {\n        \"@\": \"/src\"\n      }\n    },\n    \"build\": {\n      \"outDir\": \"dist\"\n    }\n  }\n}","lang":"typescript","description":"Shows how to install and use the plugin to extend Vite config from package.json's 'vite' field."},"warnings":[{"fix":"Use vite.config.ts for dynamic configurations.","message":"Only static config that can be JSON-serialized is supported. Functions, objects with circular references, or dynamic values cannot be placed in package.json.","severity":"gotcha","affected_versions":"*"},{"fix":"Explicitly set precedence by ordering plugins or using the 'enforce' property.","message":"The plugin merges config from package.json with vite.config.ts; duplicate config fields may cause unexpected behavior depending on merge order.","severity":"gotcha","affected_versions":"*"},{"fix":"Use Vite's official config fields like 'outDir' instead of 'output'.","message":"The 'output' alias field (e.g., 'build.output') is deprecated in Vite; use 'outDir' instead.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Ensure process.cwd() matches the directory containing package.json, or set root in Vite config.","message":"The plugin reads package.json from the project root; if the root is not correctly configured, it may fail silently.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'2.0.0':57 'across':52 'alias':40 'allow':11 'altern':32 'anthoni':23 'api':65 'base':31 'build':42 'call':69 'config':4,37,51 'configur':14 'declar':28 'develop':21 'easier':46 'extend':12 'field':18 'fu':24 'function':68 'javascript':70 'json':30 'json-bas':29 'latest':9 'like':38 'make':44 'manipul':50 'minim':64 'one':67 'output':43 'packag':3 'package.json':20 'plugin':2,7,73 'provid':26 'requir':55 'resolv':39 'share':48 'ship':58 'static':36 'tool':53 'type':60 'typescript':59,74 'v0.1.1':8 'via':15 'vite':1,6,13,17,56,72 'vite-plugin':71 'vite.config.ts':34","created_at":"2026-04-27T17:06:56.414626+00:00","updated_at":"2026-04-27T17:06:56.414626+00:00","problems":[{"fix":"Run 'npm install -D vite-plugin-package-config'.","cause":"Package not installed or missing from node_modules.","error":"Cannot find module 'vite-plugin-package-config'"},{"fix":"Use 'import PkgConfig from \"vite-plugin-package-config\"'.","cause":"Named import used instead of default import.","error":"TypeError: PkgConfig is not a function"},{"fix":"Ignore the warning; the plugin parses it correctly.","cause":"The custom 'vite' field is not part of Vite's official schema but is read by the plugin.","error":"Invalid config: field 'vite' in package.json is not recognized"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/antfu/vite-plugin-package-config","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/vite-plugin-package-config","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}