*
*
git clone https://github.com/purnasth/vite-react-tailwind-starter.git
jsx
git checkout vrt
TypeScript
git checkout vrt-ts
react-with-tailwind(v3)
git checkout tailwind-v3
*
Run the following commands in your terminal:
pnpm install
pnpm run dev
pnpm install
to install the node_modules on your local repo which has been .gitignore in this github repo.pnpm run dev
for running this in your browser, by default it opens in port http://localhost:5173/*
*
git clone https://github.com/purnasth/vite-react-tailwind-starter.git
pnpm TypeScript + Tailwindcss + Prettier (Auto Formatting)
the `main` branch
*
Run the following commands in your terminal:
pnpm install
pnpm dev
pnpm install
to install the node_modules on your local repo which has been .gitignore in this github repo.pnpm dev
for running this in your browser, by default it opens in port http://localhost:5173/NOTE:
Please disregard these below provided codes if you've already completed the first two steps of the "Getting Started" section. It's only meant for those interested in manually creating a project from scratch with Vite + React, Typescript, TailwindCSS and Prettier (Auto Formatting) with pnpm.
pnpm create vite@latest ./ --template react
# y to proceed
# Select a framework: react
# Select a variant: TypeScript + SWC
pnpm install
pnpm run dev
npm run dev -- --host
pnpm install tailwindcss @tailwindcss/vite
vite.config.ts
Update the file vite.config.ts
file:
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import tailwindcss from '@tailwindcss/vite';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), tailwindcss()],
});
index.css
Create a file named index.css
in the src
directory and add the following lines:
@import "tailwindcss";
NOTE
: In case you are migrating from tailwindcss v3.4 to v4.0, link your existing tailwind.config.js
file to the new index.css
file.
@config "../tailwind.config.js";
pnpm install -D prettier
Create a file named .prettierrc
in the root directory and add the following lines:
{
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"useTabs": false,
"printWidth": 80,
"endOfLine": "auto"
}
Add the following lines to the scripts
object in your package.json
file:
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
"format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}\""
pnpm run format
pnpm i -D prettier prettier-plugin-tailwindcss
NOTE:
Enable the formatOnSave
option in your editor to auto-format your code with Prettier. You can also run the pnpm run format
command to format your code.
Cheers! Now on every save, your code will be auto-formatted. Congratulations!
pnpm
pnpm install react-router-dom
pnpm install react-icons
⭐ Star this repo on GitHub — it helps!