Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏊‍♂️ migrated from CRA to Vite #3

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#f79311" />
<meta name="description" content="Shehzad's Youtube Clone" />
<link rel="apple-touch-icon" href="/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="/manifest.json" />

<title>Youtube Clone by Shehzad</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script src="/src/index.tsx" type="module"></script>
</body>
</html>
18,182 changes: 2,567 additions & 15,615 deletions frontend/package-lock.json

Large diffs are not rendered by default.

49 changes: 13 additions & 36 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,34 @@
"name": "youtube-clone-frontend",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"deploy": "surge ./build --domain youtube-by-shehzad.surge.sh",
"test": "react-scripts test",
"eject": "react-scripts eject"
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"deploy": "surge ./build --domain youtube-by-shehzad.surge.sh"
},
"dependencies": {
"@hookform/resolvers": "^3.3.4",
"@reduxjs/toolkit": "^2.0.1",
"@tanstack/react-query": "^5.18.0",
"axios": "^1.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.49.3",
"react-hot-toast": "^2.4.1",
"react-icons": "^4.11.0",
"react-redux": "^9.1.0",
"react-router-dom": "^6.15.0",
"react-scripts": "5.0.1",
"web-vitals": "^3.4.0",
"zod": "^3.22.2"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.48",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@types/react-stars": "^2.2.1",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
"tailwindcss": "^3.3.3",
"typescript": "^4.9.5"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
"typescript": "^4.9.5",
"vite-tsconfig-paths": "^5.0.1",
"vite": "^5.4.2"
}
}
43 changes: 0 additions & 43 deletions frontend/public/index.html

This file was deleted.

9 changes: 0 additions & 9 deletions frontend/src/App.test.tsx

This file was deleted.

46 changes: 0 additions & 46 deletions frontend/src/README.md

This file was deleted.

4 changes: 3 additions & 1 deletion frontend/src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export const getUrl = () => {
const isProduction = window.location.href.includes("https");

const baseUrl = isProduction ? "hkikik" : "http://localhost:3003";
const baseUrl = isProduction
? import.meta.env.VITE_APP_API_BASE
: "http://localhost:3003";
return baseUrl;
};

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@100;200;300;400;500;700;800;900&display=swap");

@tailwind base;
@tailwind components;
@tailwind utilities;

@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@100;200;300;400;500;700;800;900&display=swap");

* {
font-family: "Outfit", sans-serif;
}
Expand Down
6 changes: 0 additions & 6 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";
import { BrowserRouter } from "react-router-dom";
import { Provider } from "react-redux";
import { store } from "./store/store";
Expand All @@ -26,11 +25,6 @@ root.render(
</React.StrictMode>,
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
Expand Down
1 change: 0 additions & 1 deletion frontend/src/react-app-env.d.ts

This file was deleted.

15 changes: 0 additions & 15 deletions frontend/src/reportWebVitals.ts

This file was deleted.

5 changes: 0 additions & 5 deletions frontend/src/setupTests.ts

This file was deleted.

24 changes: 24 additions & 0 deletions frontend/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}
25 changes: 9 additions & 16 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
"paths": {
// "@": ["src"],
// "@/*": ["src/*"]
}
},
"include": ["src"]
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
22 changes: 22 additions & 0 deletions frontend/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["vite.config.ts"]
}
1 change: 1 addition & 0 deletions frontend/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
33 changes: 33 additions & 0 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// https://medium.com/@mun1013/guide-to-migrating-from-create-react-app-cra-to-vite-5516f55aa410
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import viteTsconfigPaths from "vite-tsconfig-paths"; // for easy importing
import tailwindcss from "tailwindcss";
// import path from "path";

// const __dirname = path.resolve();

// https://vitejs.dev/config/
export default defineConfig({
base: "./",

plugins: [react(), viteTsconfigPaths()],

server: {
open: true, // this ensures that the browser opens upon server start
port: 3000, // this sets a default port to 3000
},
resolve: {
alias: {
// "@": path.resolve(__dirname, "./src"),
},
},
build: {
outDir: "build",
},
css: {
postcss: {
plugins: [tailwindcss()],
},
},
});