Publishing an npm package with Vite library mode
Use Vite build.lib to bundle a library entry point, externalize dependencies, and wire up package.json exports for npm consumers.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Use Vite build.lib to bundle a library entry point, externalize dependencies, and wire up package.json exports for npm consumers.
Learn how to use Vite's library mode to build reusable ES module and UMD packages from a single configuration, with practical guidance on externals, package.json fields, and verification.
Vite Library Mode switches your build from an app bundle to a distributable package. Learn how to configure build.lib, manage peer dependencies, and verify the output.
Decide whether to ship ESM, CJS, UMD, or a combination from Vite library mode, see the trade-offs in a compact table, and follow a concrete build-and-validation workflow.
Learn how to use Vite’s Library mode to build a reusable UI component that outputs ES, UMD, and CJS bundles, with a concrete button example, configuration, and verification steps.