vscode-webview-boilerplate
v1.0.0
Published
Automation script to create VS Code extensions with React + Vite + Tailwind + Shadcn/UI webviews
Maintainers
Readme
VS Code React Webview Boilerplate
🚀 Automated setup script for VS Code extensions with React + Vite + Tailwind CSS + Shadcn/UI webviews.
✨ Features
- One-command setup - Complete automation from start to finish
- Modern stack - React 18, TypeScript, Vite, Tailwind CSS, Shadcn/UI
- Hot reload - Instant feedback during development
- Production-ready - esbuild bundler with optimized builds
- Path aliases - Clean imports with
@/prefix - Dark mode - Automatic theme integration
- Example components - Pre-configured Shadcn components (Button, Card)
🚀 Quick Start
Option 1: Use with npx (Recommended)
npx vscode-webview-boilerplateOption 2: Global Installation
npm install -g vscode-webview-boilerplate
vscode-webview-setupOption 3: Local Installation
npm install vscode-webview-boilerplate
node node_modules/vscode-webview-boilerplate/setup.js📋 What It Does
The script automates the entire setup process:
- Creates VS Code extension (or adds to existing one)
- Sets up React + Vite webview project
- Configures TypeScript with path aliases
- Installs Tailwind CSS with dark mode support
- Sets up Shadcn/UI component library
- Copies pre-built components (Button, Card, utils)
- Configures bundlers (esbuild for extension, Vite for webview)
- Sets up hot reload for instant development feedback
- Updates package.json with VS Code contributes
- Patches extension.ts with WebviewProvider registration
- Creates development tasks for watch mode
🎯 Requirements
- Node.js 18+
- npm 7+
- VS Code (for testing)
💡 Usage
After running the script, you'll be guided through:
- Project type - New project or existing extension
- Webview configuration - View ID, title, location
- Optional setup - Tailwind CSS and Shadcn/UI
- Integration - Automatic or manual file updates
New Project
npx vscode-webview-boilerplate
# Choose "Create a new project from scratch"
# Follow the yo code wizard instructionsExisting Extension
cd your-existing-extension
npx vscode-webview-boilerplate
# Choose "I already have an extension project"🛠️ Post-Setup Commands
# Development mode (watch + hot reload)
npm run watch
# Build for production
npm run compile
# Test extension
Press F5 in VS Code📦 What's Included
Configuration Files
esbuild.js- Extension bundlervite.config.ts- Webview bundler.vscode/tasks.json- Parallel watch taskstsconfig.json- TypeScript configuration
Template Files
WebviewProvider.ts- Webview provider with hot reloadApp.tsx- React entry point with Shadcn exampleindex.css- Tailwind + Shadcn variablescomponents/ui/- Shadcn components (Button, Card)lib/utils.ts- Utility functions (cn helper)
🎨 Customization
After setup, you can:
- Add more Shadcn components:
npx shadcn@latest add <component> - Modify theme: Edit CSS variables in
index.css - Add routes: Install
react-router-domfor multi-page webviews - State management: Add Zustand, Jotai, or Redux
- API calls: Use
vscode.postMessage()for extension communication
🔧 Troubleshooting
Build errors
npm run clean # Remove dist folder
npm run compileWebview not loading
- Check browser console in webview (Ctrl+Shift+I)
- Verify
dist/webview/contains built files - Ensure view ID matches in all files
Hot reload not working
- Restart watch mode:
npm run watch - Check terminal for build errors
- Verify Vite dev server is running on port 5173
📚 Documentation
For detailed technical documentation, see:
- templates/README.md - Template file reference
🤝 Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
📄 License
MIT License - See LICENSE for details
