Vite
Install and configure Vite.
1
Create a new project
npm create vite@latest
2
Install dependencies
cd my-app && npm i
3
Install Tailwind v4
npm i tailwindcss @tailwindcss/vite
4
Put the following code in styles/globals.css
styles/globals.css
@import "tailwindcss";
5
Edit tsconfig.json file
tsconfig.json
{
// ...
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
// ...
}
6
Edit tsconfig.app.json file
tsconfig.app.json
{
"compilerOptions": {
// ...
"baseUrl": ".",
"paths": {
"@/*": [
"./src/*"
]
}
// ...
}
}
7
Update vite.config.ts
Terminal
# 'path' doesn't work without this package
npm i -D @types/node
vite.config.ts
import { defineConfig } from "vite"
import react from "@vitejs/plugin-react"
import path from "path"
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
})