vite-react-library-setup

Convert an unbuilt React project into a publishable Vite 5 library.

Updated Jul 7, 2026
One-click install
npx skills add https://github.com/TitoPrausee/nexus-toti --skill vite-react-library-setup
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vite-react-library-setup
Source: https://github.com/TitoPrausee/nexus-toti/tree/main/data/skills/software-development/vite-react-library-setup
Command: npx skills add https://github.com/TitoPrausee/nexus-toti --skill vite-react-library-setup

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill turns a React project that lacks a proper build pipeline into a publishable npm component library with modern bundling, correct package exports, and automatic stylesheet delivery.

Core Features & Use Cases

  • Dual Build Output: Produces both ESM and CommonJS artifacts so the library works across modern bundlers and older Node-based consumers.
  • CSS Bundling: Ensures component styles are included in the published build instead of being left behind in source files.
  • Package Publish Readiness: Updates the package configuration so the library can be installed cleanly with proper main, module, exports, and files settings.
  • Use Case: A React UI kit with JSX inside source files can be converted into a distributable package that consumers import without needing their own transpilation setup.

Quick Start

Ask the assistant to convert your React source tree into a Vite 5 library build with dual module outputs, bundled CSS, and a publish-ready package configuration.

Frequently Asked Questions about vite-react-library-setup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build and publish a React component library with Vite?

Building and publishing a React component library with Vite requires configuring a Vite 5 library setup that produces dual ESM and CJS outputs, bundles CSS, and defines proper package exports for clean npm installation.

Why does my Vite React library build output both ESM and CommonJS?

A Vite React library build outputs both ESM and CommonJS to ensure compatibility across modern bundlers and older Node-based consumers. Dual module distribution allows your package to be imported correctly regardless of the consumer's module resolution system.

How do I bundle CSS into my React npm package?

To bundle CSS into your React npm package, you must ensure component styles are imported through a CSS entry file and processed by the Vite library build. This includes the stylesheets directly in the published artifacts instead of leaving them in source files.

What package.json configuration is needed to publish a Vite React library?

Publishing a Vite React library requires a non-private package.json with correct main, module, exports, and files settings. You must also configure React as a peer dependency to prevent version conflicts when consumers install your library.

Do I need to set React as a peer dependency when publishing a component library?

Yes, you need to set React as a peer dependency when publishing a component library. React peer-dependency handling ensures that the consumer's existing React installation is used, preventing duplicate React instances and avoiding component rendering conflicts.

Can I convert an unbuilt React project into a publishable npm package?

Yes, you can convert an unbuilt React project into a publishable npm package by applying a Vite 5 library build pipeline. This process handles JSX transpilation, CSS bundling, and package configuration updates to make the source tree distribution-ready.