vite-lib-vue-pnpm-starter-skill
1
总安装量
1
周安装量
#46985
全站排名
安装命令
npx skills add https://github.com/lizychy0329/vite-lib-vue-pnpm-starter-skill --skill vite-lib-vue-pnpm-starter-skill
Agent 安装分布
trae-cn
1
Skill 文档
Vite Lib Vue 3 PNPM Starter Skill
This skill creates a minimal Vite + Vue 3 library project template using pnpm workspace for dependency management. It directly generates all necessary files without using Vite’s official initialization commands.
Core Features
- Directly generate all configuration files without manual intervention
- pnpm workspace for monorepo structure management
- Vue 3 + TypeScript support
- Minimal configuration approach
- pnpm package manager only
Usage Workflow
1. Create Project Directory Structure
mkdir -p src/components
mkdir -p playground/src
mkdir -p playground/public
2. Generate Configuration Files
Generate the following essential files:
- Root
package.jsonwith workspace configuration and build scripts pnpm-workspace.yamlfor monorepo setupvite.config.tswith library build configuration- TypeScript configuration files (
tsconfig.json,tsconfig.app.json,tsconfig.node.json) - Library entry files (
index.ts,src/index.ts,src/components/index.ts) - Example component (
src/components/Counter.vue) - Playground files (
playground/package.json,playground/vite.config.ts,playground/index.html, etc.) .gitignorefile
3. Install Dependencies
pnpm install
4. Validate Setup
Build Validation
pnpm build
Expected Result:
- Successful build with no errors
- Generated
dist/directory - Files:
index.es.js,index.umd.js,index.d.ts
Development Validation
cd playground && pnpm dev
Expected Result:
- Development server starts successfully
- No compilation errors
- No TypeScript errors
- Accessible development page
Project Structure
project-root/
âââ .gitignore
âââ index.ts
âââ package.json
âââ pnpm-workspace.yaml
âââ tsconfig.json
âââ tsconfig.app.json
âââ tsconfig.node.json
âââ vite.config.ts
âââ src/
â âââ index.ts
â âââ components/
â â âââ index.ts
â â âââ Counter.vue
â âââ style.css
âââ playground/
â âââ .gitignore
â âââ index.html
â âââ package.json
â âââ tsconfig.json
â âââ tsconfig.app.json
â âââ tsconfig.node.json
â âââ vite.config.ts
â âââ public/
â âââ src/
â âââ main.ts
â âââ App.vue
â âââ style.css
â âââ assets/
âââ dist/ (generated after build)
Key Implementation Details
Library Configuration
- Set
vueas external dependency invite.config.ts - Use
vite-plugin-dtsfor TypeScript declaration generation - Configure proper exports in
package.jsonfor different module systems
TypeScript Setup
- Use TypeScript Project References for better compilation performance
- Strict TypeScript settings for improved code quality
Playground Setup
- Reference main library via
workspace:*for local development - Separate configuration for isolated testing environment
When to Use This Skill
- Creating a new Vue 3 component library
- Using Vite as the build tool
- Preferring pnpm for package management
- Needing a playground for local testing
- Requiring TypeScript type declarations
Important Notes
- pnpm Only: Project is configured exclusively for pnpm
- Minimal Configuration: Keep settings lean and focused
- Direct File Generation: No Vite official commands used
- Workspace Dependency: Playground uses
workspace:*for latest code - Type Checking:
vue-tsc -bruns before build - External Vue: Vue is not bundled into the library
- TypeScript References: For optimal compilation
Troubleshooting
Q: Why pnpm instead of npm?
A: Faster installation, stricter dependency management, and better monorepo support.
Q: Why separate package.json for playground?
A: Isolated environment with its own dependencies, referencing main library via workspace.
Q: Why externalize Vue in build?
A: Avoids duplicate bundling and version conflicts, follows library best practices.
Q: Why use TypeScript References?
A: Enables independent compilation of subprojects for faster builds and more accurate type checking.