
Vite
Configure Vite library mode, multi-page entries, package exports, and SSR-oriented build setup for shippable frontends and publishable JS libraries.
Overview
Vite is an agent skill for the Build phase that configures Vite library mode, multi-page builds, package exports, and SSR-related build patterns.
Install
npx skills add https://github.com/antfu/skills --skill viteWhat is this skill?
- Library mode with named UMD/ES outputs and Vue/React externals via rolldownOptions
- Multiple entry points for secondary bundles alongside a primary lib entry
- Package.json exports pattern for import, require, and style.css subpaths
- Multi-page app input wiring through rolldown build options
- SSR-oriented build guidance bundled with standard Vite defineConfig workflows
- Source snapshot generated 2026-01-31 from pinned git SHA c47015eba4f0de255218c35769628d87152216ca
Adoption & trust: 25.6k installs on skills.sh; 5.2k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You have a Vite app or library but lack correct lib mode, multi-entry, or package.json exports and worry the published bundle will break consumers.
Who is it for?
Solo builders publishing a Vite-based component library, multi-page SaaS shell, or SSR frontend who need copy-paste-correct config snippets.
Skip if: Projects using webpack-only pipelines with no Vite migration plan, or teams needing full SSR runtime hosting playbooks without any build config work.
When should I use this skill?
Configuring Vite library builds, multi-page apps, JavaScript API usage, or SSR-related build setup.
What do I get? / Deliverables
You leave with a defineConfig setup—entries, externals, and exports—ready to build dist artifacts for npm or deployed static/SSR targets.
- vite.config.ts patterns for lib and MPA targets
- package.json exports and files array suitable for npm publish
Recommended Skills
Journey fit
Vite build and SSR guidance sits in Build because it produces distributable bundles and library artifacts, not launch distribution tactics. Frontend subphase is correct for vite.config.ts, Rolldown externals, and package.json export maps that define how users consume your UI or lib.
How it compares
Skill package for Vite build config, not a hosted CI/CD pipeline or deployment MCP server.
Common Questions / FAQ
Who is vite for?
Indie frontend developers and agent-assisted coders standardizing Vite library and MPA builds before npm or production deploy.
When should I use vite?
During Build frontend work when defining library mode, multiple Rollup/Rolldown inputs, exports fields, or SSR build options in vite.config.ts.
Is vite safe to install?
Check the Security Audits panel on this Prism page for repository and skill bundle signals before installing into Claude Code, Cursor, or Codex.
SKILL.md
READMESKILL.md - Vite
# Generation Info - **Source:** `sources/vite` - **Git SHA:** `c47015eba4f0de255218c35769628d87152216ca` - **Generated:** 2026-01-31 --- name: vite-build-ssr description: Vite library mode, multi-page apps, JavaScript API, and SSR guidance --- # Build and SSR ## Library Mode Build a library for distribution: ```ts // vite.config.ts import { resolve } from 'node:path' import { defineConfig } from 'vite' export default defineConfig({ build: { lib: { entry: resolve(import.meta.dirname, 'lib/main.ts'), name: 'MyLib', fileName: 'my-lib', }, rolldownOptions: { external: ['vue', 'react'], output: { globals: { vue: 'Vue', react: 'React', }, }, }, }, }) ``` ### Multiple Entries ```ts build: { lib: { entry: { 'my-lib': resolve(import.meta.dirname, 'lib/main.ts'), secondary: resolve(import.meta.dirname, 'lib/secondary.ts'), }, name: 'MyLib', }, } ``` ### Output Formats - Single entry: `es` and `umd` - Multiple entries: `es` and `cjs` ### Package.json Setup ```json { "name": "my-lib", "type": "module", "files": ["dist"], "main": "./dist/my-lib.umd.cjs", "module": "./dist/my-lib.js", "exports": { ".": { "import": "./dist/my-lib.js", "require": "./dist/my-lib.umd.cjs" }, "./style.css": "./dist/my-lib.css" } } ``` ## Multi-Page App ```ts export default defineConfig({ build: { rolldownOptions: { input: { main: resolve(import.meta.dirname, 'index.html'), nested: resolve(import.meta.dirname, 'nested/index.html'), }, }, }, }) ``` ## SSR Development **Note:** Vite's SSR support is **low-level** and designed mostly for meta-framework authors, not application developers. If you need SSR for your app, use a Vite-based meta-framework instead: - **Nuxt** (Vue) - https://nuxt.com - **SvelteKit** (Svelte) - https://svelte.dev/docs/kit - **SolidStart** (Solid) - https://start.solidjs.com - **TanStack Start** (React) - https://tanstack.com/start These frameworks build on top of Vite's SSR primitives so you don't have to wire them up yourself. **Need a server?** Consider [Nitro](https://nitro.build) -- think of it as "Vite for servers." Nitro provides a portable, framework-agnostic server layer with file-based API routing, auto-imports, and deployment presets for dozens of platforms (Node.js, Deno, Bun, Cloudflare Workers, Vercel, Netlify, etc.). It integrates naturally with Vite and is what powers Nuxt's server engine. See the [Nitro docs](https://nitro.build) for more details. ## JavaScript API ### createServer ```ts import { createServer } from 'vite' const server = await createServer({ configFile: false, root: import.meta.dirname, server: { port: 1337 }, }) await server.listen() server.printUrls() ``` ### build ```ts import { build } from 'vite' await build({ root: './project', build: { outDir: 'dist' }, }) ``` ### preview ```ts import { preview } from 'vite' const previewServer = await preview({ preview: { port: 8080, open: true }, }) previewServer.printUrls() ``` ### resolveConfig ```ts import { resolveConfig } from 'vite' const config = await resolveConfig({}, 'build') ``` ### loadEnv ```ts import { loadEnv } from 'vite' const env = loadEnv('development', process.cwd(), '') // Loads all env vars (empty prefix = no filtering) ``` <!-- Source references: - https://vite.dev/guide/build - https://vite.dev/guide/api-javascript - https://nitro.build --> --- name: vite-config description: Vite configuration patterns using vite.config.ts --- # Vite Configuration ## Basic Setup ```ts // vite.config.ts import { defineConfig } from 'vite' export default defineConfig({ // config options }) ``` Vite auto-resolves `vite.config.ts` from project root. Supports ES modules syntax regardless of `package.json` type. ## Conditional Config Export a function to access command and mode: ```ts export default defineCon