Setup react.js project using vite (step-by-step)
1- Create project:
2- Install dependencies:
3- Add Tailwind:
4- Replace the whole 'src/index.css' by:
** You can remove App.css file and its import in App.tsx (not usable).
5- Replace the whole 'tsconfig.json' by:
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}
6- Add below line to "compilerOptions" in 'tsconfig.app.json' (for resolving path in your IDE):
7- Replace the whole 'vite.config.ts' by:
import path from "path";
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
// https://vite.dev/config/
export default defineConfig({
plugins: [react(), tailwindcss()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
});
8- Add shadcn:
** Now you can add shadcn components by:
9- Run project: