React
Vite
Published on: Jan 2, 2025
-
Terminal window npm create vite@latest react-app -- --template react-tsCreate a new React project using Vite.
-
package.json {"name": "react-app","private": true,"version": "0.0.0","type": "module","scripts": {"dev": "vite","build": "tsc -b && vite build","lint": "eslint .","preview": "vite preview"},"dependencies": {"react": "^18.3.1","react-dom": "^18.3.1","react": "^19.0.0","react-dom": "^19.0.0",},"devDependencies": {"@eslint/js": "^9.17.0","@types/react": "^18.3.18","@types/react-dom": "^18.3.5","@types/react": "^19.0.2","@types/react-dom": "^19.0.2","@vitejs/plugin-react": "^4.3.4","eslint": "^9.17.0","eslint-plugin-react-hooks": "^5.0.0","eslint-plugin-react-refresh": "^0.4.16","globals": "^15.14.0","typescript": "~5.6.2","typescript-eslint": "^8.18.2","vite": "^6.0.5"}}Increase the version of React and React DOM to the latest versions.
-
Terminal window npm installInstall the dependencies.
-
Terminal window npm install -D tailwindcss postcss autoprefixerInstall Tailwind CSS dependencies.
-
Terminal window npx tailwindcss init -pGenerate the Tailwind CSS configuration files.
-
tailwind.config.js /** @type {import('tailwindcss').Config} */export default {content: [],content: ["./index.html","./src/**/*.{js,ts,jsx,tsx}",],theme: {extend: {},},plugins: [],}Set up the Tailwind CSS configuration.
-
index.css @tailwind base;@tailwind components;@tailwind utilities;Add the Tailwind directives.
-
App.tsx export default function App() {return (<h1 className="text-3xl font-bold underline">Hello world!</h1>)}Use Tailwind CSS classes in the React component.