InstallationVite
Vite
Install and configure Vite.
1
Create a new project
Terminal
npm create vite my-app
2
After the above command, install and enter the application
Terminal
cd my-app && npm i
3
Add Tailwind CSS
Terminal
npm i -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
4
Edit tsconfig.json
file
tsconfig.json
{
// ...
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
// ...
}
5
Edit tsconfig.app.json
file
tsconfig.app.json
{
"compilerOptions": {
// ...
"baseUrl": ".",
"paths": {
"@/*": [
"./src/*"
]
}
// ...
}
}
6
Update vite.config.ts
Terminal
# So you can import 'path' without error
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"),
},
},
})