This script automates the setup of a new React project using Vite, along with optional installations of various libraries. It also configures ESLint and Vite for your project.
- Creates a new Vite project with React template
- Installs optional libraries based on user input
- Configures ESLint and Vite with the appropriate plugins and settings
- Sets up project structure and initial files
- Clear and update the App.jsx and index.css.
- Delete unnecessary files and folders.
- Opens the project in Visual Studio Code
Ensure you have the following installed:
- Node.js (latest LTS version)
- npm (Node Package Manager)
- Visual Studio Code (optional, for opening the project)
-
Clone this repository:
git clone https://github.com/your-username/your-repository.git cd your-repository
-
Make the script executable (on Unix-based systems):
chmod +x create-react-vite-project.js
-
Run the script:
node create-react-vite-project.js
-
Follow the prompts to set up your project.
The script will first prompt you for:
- The name of your project
- Whether to install additional libraries (Tailwind CSS, Framer Motion, GSAP, etc.)
Based on your responses:
- A new Vite project will be created with the React template.
- Libraries you chose will be installed.
- ESLint and Vite configuration files will be set up.
- ESLint Configuration:
.eslintrc.cjs
- Vite Configuration:
vite.config.js
- File and Directory Structure: Creates necessary directories and updates key files (e.g.,
App.jsx
,index.css
).
- Opens the newly created project in Visual Studio Code (optional).
Here is how the script will execute:
Enter the name of your project: my-react-app
Install Tailwind CSS? (y/n): y
Install Framer Motion? (y/n): n
Install GSAP? (y/n): y
Install React Query? (y/n): y
...
-
Dependency Conflicts: If you encounter dependency conflicts, you may need to use the
--legacy-peer-deps
option with npm commands. -
File Permissions: Ensure the script has execute permissions (on Unix-based systems) using
chmod +x create-react-vite-project.js
.
Feel free to submit issues or pull requests to improve the script.