UNPKG

create-vite-pp

Version:

CLI to scaffold a Vite + React + Tailwind project with JS/TS option

352 lines (250 loc) โ€ข 8.21 kB
# create-vite-pp ๐Ÿš€ > **Lightning-fast React + Vite + Tailwind CSS project generator** A powerful CLI tool that scaffolds a complete React project with Vite and Tailwind CSS in under 30 seconds. No more repetitive setup - just answer 2 questions and start coding! [![npm version](https://badge.fury.io/js/create-vite-pp.svg)](https://badge.fury.io/js/create-vite-pp) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Node.js Version](https://img.shields.io/badge/node-%3E%3D14.0.0-brightgreen)](https://nodejs.org/) ## โœจ Features - ๐Ÿš€ **Ultra Fast Setup** - Complete project in 30 seconds - ๐Ÿ” **Smart Validation** - Prerequisites check & name validation - ๐ŸŽฏ **Interactive CLI** - User-friendly prompts with validation - โšก **Latest Tech Stack** - Vite, React 18, TailwindCSS v3.4+ - ๐Ÿ“ **Language Choice** - JavaScript or TypeScript support - ๐ŸŽจ **Zero Configuration** - Perfect configs out of the box - ๐Ÿงน **Clean Boilerplate** - No unnecessary code cluttering - ๐Ÿ“š **Auto Documentation** - Comprehensive README generation - ๐Ÿ›ก๏ธ **Error Handling** - Graceful failures with helpful messages - ๐Ÿ”„ **Latest Dependencies** - Always uses current versions ## ๐Ÿš€ Quick Start ```bash # Using npx (recommended) npx create-vite-pp # Or install globally npm install -g create-vite-pp create-vite-pp ``` ## ๐Ÿ“‹ Requirements - **Node.js** โ‰ฅ 14.0.0 - **npm** โ‰ฅ 6.0.0 _The CLI automatically checks these prerequisites before starting._ ## ๐ŸŽฏ Usage ### Interactive Mode Simply run the command and follow the prompts: ```bash $ npx create-vite-pp ================================================== ๐Ÿš€ React + Vite + Tailwind Setup ================================================== ? Enter your project name: โ€บ my-awesome-app ? Select language: โ€บ โฏ JavaScript TypeScript โœ“ Prerequisites check passed โณ Creating Vite project... โœ“ Vite project created successfully โณ Installing dependencies... โœ“ Dependencies installed successfully โณ Setting up Tailwind CSS... โœ“ Tailwind CSS setup completed โณ Updating App component... โœ“ App component updated โณ Creating README... โœ“ README created ================================================== ๐ŸŽ‰ Setup Complete! ================================================== Next steps: 1. cd my-awesome-app 2. npm run dev 3. Open http://localhost:5173 โœ“ Your React + Vite + Tailwind project is ready! ``` --- ### Project Structure The CLI creates a well-organized project structure: ``` my-awesome-app/ โ”œโ”€โ”€ public/ # Static assets โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ assets/ # Images, icons, etc. โ”‚ โ”œโ”€โ”€ App.jsx (or .tsx) # Main App component โ”‚ โ”œโ”€โ”€ App.css # Component styles โ”‚ โ”œโ”€โ”€ index.css # Global styles (Tailwind imports) โ”‚ โ””โ”€โ”€ main.js (or .ts) # Application entry point โ”œโ”€โ”€ index.html # HTML template โ”œโ”€โ”€ package.json # Dependencies and scripts โ”œโ”€โ”€ tailwind.config.js # Tailwind configuration โ”œโ”€โ”€ postcss.config.js # PostCSS configuration โ”œโ”€โ”€ vite.config.js # Vite configuration โ””โ”€โ”€ README.md # Project documentation ``` ## ๐Ÿ› ๏ธ What Gets Installed ### Core Dependencies - **React** ^18.2.0 - Modern React with hooks - **React-DOM** ^18.2.0 - React DOM renderer ### Development Dependencies - **Vite** ^5.0.0+ - Lightning-fast build tool - **TailwindCSS** ^3.4.0 - Utility-first CSS framework - **@tailwindcss/postcss** - PostCSS integration - **Autoprefixer** - CSS vendor prefixes - **ESLint** - Code linting (React configuration) ### TypeScript (if selected) - **TypeScript** ^5.0.0+ - Static type checking - **@types/react** - React type definitions - **@types/react-dom** - React DOM type definitions ## โš™๏ธ Configuration Details ### Tailwind Configuration ```javascript // tailwind.config.js export default { content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"], theme: { extend: {}, }, plugins: [], }; ``` ### PostCSS Configuration ```javascript // postcss.config.js export default { plugins: { tailwindcss: {}, autoprefixer: {}, }, }; ``` ### CSS Setup The generated `src/index.css` includes: ```css @tailwind base; @tailwind components; @tailwind utilities; ``` ## ๐ŸŽจ Clean Boilerplate Unlike other generators, `create-vite-pp` provides a minimal, clean starting point: ```jsx function App() { return ( <div className="min-h-screen relative bg-black"> {/* Attribution */} <div className="fixed bottom-4 right-4 text-xs text-gray-400"> โ€” Pritam Paul โ€” </div> </div> ); } export default App; ``` Perfect for starting your project without removing unnecessary code! ## ๐Ÿšฆ Available Scripts After project creation, you can run: ```bash # Start development server npm run dev # Build for production npm run build # Preview production build npm run preview # Run linting npm run lint ``` ## ๐Ÿ” Validation Features ### Project Name Validation - โœ… Non-empty names - โœ… Valid characters (alphanumeric, hyphens, underscores) - โœ… No directory conflicts - โœ… Proper naming conventions ### Prerequisites Check - โœ… Node.js installation - โœ… npm availability - โœ… Version compatibility ## ๐ŸŽฏ Advanced Usage ### Handling Errors The CLI provides helpful error messages: ```bash โœ— Command failed: npm install โœ— Error: Network timeout ``` ### Interruption Handling Safe interruption with `Ctrl+C`: ```bash โœ— Setup interrupted ``` ## ๐Ÿค Contributing Contributions are welcome! Please feel free to submit a Pull Request. ### Development Setup ```bash # Clone the repository git clone https://github.com/pritam-pauldev/create-vite-pp.git cd create-vite-pp # Install dependencies npm install # Test locally npm link create-vite-pp test-project ``` ### Building ```bash # Test the package npm run start # Publish to npm npm publish ``` ## ๐Ÿ“ Changelog ### v1.0.8 - โœ… Added TypeScript support - โœ… Improved error handling - โœ… Updated to TailwindCSS v3.4+ - โœ… Enhanced project validation - โœ… Better README generation ### v1.0.7 - โœ… Initial release - โœ… Basic Vite + React + Tailwind setup - โœ… Interactive CLI prompts ## ๐Ÿ› Troubleshooting ### Common Issues **Issue**: `npm ERR! EACCES: permission denied` ```bash # Solution: Fix npm permissions npm config set prefix ~/.npm-global export PATH=~/.npm-global/bin:$PATH ``` **Issue**: `Command 'create-vite-pp' not found` ```bash # Solution: Install globally or use npx npm install -g create-vite-pp # OR npx create-vite-pp ``` **Issue**: Slow installation ```bash # Solution: Use faster npm registry npm config set registry https://registry.npmjs.org/ ``` ## ๐Ÿ“Š Performance - **Setup Time**: ~30 seconds - **Package Size**: ~24 dependencies - **Node.js Requirement**: โ‰ฅ14.0.0 - **Cross-Platform**: โœ… Windows, macOS, Linux ## ๐Ÿ”— Related Projects - [Vite](https://vitejs.dev/) - Next generation frontend tooling - [React](https://reactjs.org/) - A JavaScript library for building user interfaces - [Tailwind CSS](https://tailwindcss.com/) - Rapidly build modern websites ## ๐Ÿ“„ License MIT License - see the [LICENSE](LICENSE) file for details. ## ๐Ÿ‘จโ€๐Ÿ’ป Author **Pritam Paul** - GitHub: @pritam-pauldev - LinkedIn: linkedin.com/in/pritam-dev - Email: pritampaulcontactme@gmail.com ## ๐Ÿ™ Acknowledgments - The Vite team for the amazing build tool - The React team for the fantastic library - The Tailwind CSS team for the utility-first framework - All contributors and users of this package --- <div align="center"> **[โญ Star this repo](https://github.com/pritam-pauldev/create-vite-pp) if you found it helpful!** Made with โค๏ธ by **Pritam Paul** </div>